I’m having real problems with the PHP move_uploaded_file command to work properly on a shared Apasche web hosting server.
If I want to create a folder (mkdir) I have to use the full path name, e.g.
$target_path = "/home/myhostingname/public_html/uploads/files/".$lastID;
mkdir($target_path, 0755);
That works, the unique folder is created and using FileZilla I can upload files to it.
However when I try and use the full path with the move_uploaded_file command nothing ever gets uploaded. E.g.
move_uploaded_file($tmp_file, $target_path);
where, e.g. :
$tmp_file = "/home/myhostingname/public_html/tmp/php8MR5Qv/test.gif"
$target_path = "/home/myhostingname/public_html/uploads/files/130/"
Any ideas what I’m doing wrong. The script is accepted but there would appear to be a mismatch going on…
File from
$tmp_fileshould be uploaded via HTTP POST request, otherwisemove_uploaded_filewill not work.To check if file has been uploaded use
is_uploaded_fileSo your code might look like this: