i have a script for my users to upload files to my server...
the upload directory is chmod to 777 and files upload properly.
the only trouble is that I am having trouble getting it to verify if a filename is in use or not, it just overwrites the file regardless, can someone take a look and tell me what i'm missing?
here is the code
Code:
$file_dir = "./files";
foreach($_FILES as $file_name => $file_array)
{
echo "Creating temporary file..... ".$file_array['tmp_name']."
\n";
echo "Checking file name: ".$file_array['name']."
\n";
echo "File type: ".$file_array['type']."
\n";
echo "File size: ".$file_array['size']."
\n";
if (is_uploaded_file($file_array['tmp_name']))
{
move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]")
or die ("Couldn't copy, file name already in use.");
echo "File was moved successfully.
";
}
}
this is based off of sams teach yourself php books script
all works except the verifying a filename