0

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?

matthy
  • 8,144
  • 10
  • 38
  • 47

2 Answers2

3

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.

Andrew Moore
  • 93,497
  • 30
  • 163
  • 175
0

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

dusoft
  • 11,289
  • 5
  • 38
  • 44
  • "try to set your custom temp path." how? – matthy Aug 01 '09 at 19:18
  • if you can edit php.ini, then do it. if not, try to change value via ini_set() – dusoft Aug 01 '09 at 19:24
  • **@dusoft:** I really don't think the `/tmp` directory is the problem here. The error message indicates that it wrote to `/tmp` without any problems. It's the directory he moves the files into that doesn't have `+w+x`. – Andrew Moore Aug 01 '09 at 19:27