I want to upload a file to my server (Apache on RaspberryPi (raspbian) in my home network) over https and then write it to disk with PHP. I'm getting the move_uploaded_file(): Unable to move '/tmp/php2W6AMo' Permission denied
Error. To solve this, I try to change the directory for the temporary upload files, but it's not working properly.
This Code:
<?php
ini_set('upload_tmp_dir', '/var/www/upload_tmp_dir/');
echo ini_get('upload_tmp_dir') .'
';
print_r($_FILES);
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "It worked.
";
} else {
echo "Error!
";
}
?>
produces following output:
/var/www/upload_tmp_dir
Array
(
[userfile] => Array
(
[name] => test.txt
[type] => application/octet-stream
[tmp_name] => /tmp/phpq9iDg3
[error] => 0
[size] => 124184
)
)
The php.ini
says this: /var/www/upload_tmp_dir
. Same for phpinfo()
.
Why does it still upload the files to /tmp
?
Is there anything I've overseen?
Thank you for your help.