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
$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