Click to See Complete Forum and Search --> : File Upload Problem


auxone
05-09-2008, 03:16 PM
I have read over countless PHP uploading articles, but I still have an issue. I already have the file from my HTML form (named 'uploaded_file'). The following code always exits on the 'Failed!...' error.

$uploadsDirectory = dirname(__FILE__).'/uploaded_images/';
$now = 1; // move file, make sure no duplicates
while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES['uploaded_file']['name']))
{
$now++;
}

// move the file to its final location and allocate the new filename to it
@move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadFilename)
or error('Failed! Receiving directory has insuffiecient permissions.');

I have the directory set to 777. Maybe my $uploadsDirectory is pointing to a different place, but I tried every permutation I could. I even tried just plain $uploadDirectory = "uploaded_images/", with the same error.

Anyone have an idea?
Tyler

SyCo
05-09-2008, 04:27 PM
when you echo
$uploadsDirectory

does it look like you'd expect?

auxone
05-09-2008, 05:01 PM
Problem solved, but thanks for the input. The temp directory in the php.ini file wasn't properly set to my home temp. It was set to the system temp from which I was not allowed to copy files.

Thanks again.