matthy
matthy

Reputation: 8334

php function move_uploaded_file wont work on my online server but does on localhost

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?

Upvotes: 0

Views: 2758

Answers (2)

Andrew Moore
Andrew Moore

Reputation: 95444

Make sure that /home/taalhulp/domains/taalhulpmanager.nl/public_html/files/'s permissions are set to 0777.

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.

Upvotes: 3

dusoft
dusoft

Reputation: 11469

you probably don't have permissions (PHP engine / apache webserver) to access the directory for temporary uploads. try to set your custom temp path.

Upvotes: 0

Related Questions