Jump to content

move_uploaded_file not working


BritSteve
Go to solution Solved by BritSteve,

Recommended Posts

Hi,

 

I am uploading a file from a form and trying to move it to another directory and it is not working, and I am not seeing any errors.

 

I am actually trying to move an xlsx file, but when that didn't work. I even tried a simple txt file and it still didn't work, so I don't think it is the file type.

 

This is my debug output.

 

new_move_filename is /home/xxxxxx/www/orders/admintest/xxxxxx/infiles/03042018085633.xlsx
ERROR: Unable to move xxxxx upload file to input directory /home/xxxxxx/www/orders/admintest/xxxxx/infiles!. Error is '' Check permissions and please try again.
Debug information
-----------------
Array ( [xxxx_file] => Array ( [name] => PO_Data_2017-03-22_14-44-07PST.xlsx [type] => application/vnd.openxmlformats-officedocument.spreadsheetml.sheet [tmp_name] => /tmp/phpLCxh0I [error] => 0 => 5980 ) )
 
The input directory does definitely exist, and I have tried 755 and 777 permissions.
 
Below is the code. I have x'd out some directory information for security reasons.
 
# Get a nice unique filename based on the date and time.
$filename_date_bit = date('mdYhis');
# Move file to xxxxx input directory.
$new_move_filename = $xxxx_indir . "/" . $filename_date_bit . ".xlsx";
echo "new_move_filename is $new_move_filename<br>";
$ret = move_uploaded_file($_FILES["xxxx_file"]["name"], $new_move_filename);
if (! $ret)
{
echo ("ERROR: Unable to move xxxxx upload file to input directory $xxxxx_indir!. Error is '$ret' Check permissions and please try again.");
echo "<p>Debug information<br>";
echo "-----------------<br>";
print_r($_FILES);
exit;
}

 

Can anyone please give me some ideas where to look?

 

Thanks,

 

Steve

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.