I have been working on a upload file that works fine on localhost (windows) but wont work on my linux server I rent. I want it to move it to a subdir ‘/files’ from where the file is.
it gives the errors:
Warning: move_uploaded_file(/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/taalhulp/domains/taalhulpmanager.nl/public_html/Gegev_Dossier.php on line 66
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/tmp/phpFMaeAs’ to ‘/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6’ in /home/taalhulp/domains/taalhulpmanager.nl/public_html/Gegev_Dossier.php on line 66
Here is a simplified version of my code
$FotoMap = '/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/' ;
if ($_POST['type'] == 'add' & strlen($_FILES['FileUpload']['name']) > 0 && strlen($_POST["GivenFileName"]) > 0 )
{
if (move_uploaded_file($_FILES['FileUpload']['tmp_name'], $FotoMap . $file_name_id))
{
$_SESSION['echo'] = 'succes';
}
else
{
$_SESSION['echo'] = 'fail';
}
}
it says permission denied but is that because I do something wrong or because i need to contact my provider to tell him to enable that, maybe you I can enable that myself?
Make sure that
/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/‘s permissions are set to0777.I do not recommend doing that as it opens a bunch of security issues. You would be better finding out on which user or group the script is being run and modify the directory to be owned by that user instead.