1

So i'm receiving a warning on uploading an image:

Warning: move_uploaded_file(images/photo.jpg): failed to open stream: Permission denied..

Here is the code:

$upload = "images/";
$tmp_name = $_FILES["image"]["tmp_name"];
$name = $_FILES["image"]["name"];
move_uploaded_file($tmp_name, "$upload/$name");

Now if I go to the images directory in putty and type ls -la I get:

drwxrwxrwx+ user daemon 96 Apr 16 12:41 .
drwxrwxrwx+ user daemon 96 Apr 16 12:41 ..

Not entirely sure what this means, I assume I have read write execute permissions.

I tried chmod 0777 but I still receive the error.

Can anyone tell me how I can upload the images without the permissions error.

stark
  • 287
  • 4
  • 9
  • 20
  • possible duplicate of [move\_uploaded\_file gives "failed to open stream: Permission denied " error after all configurations i did](http://stackoverflow.com/questions/8103860/move-uploaded-file-gives-failed-to-open-stream-permission-denied-error-after) – Yuva Raj Apr 18 '15 at 12:33
  • I've tried everything in this question suggestion.. and nothing worked, so I posted this one. – stark Apr 18 '15 at 12:35

1 Answers1

1

Give permission to the folder

   $upload = "images/";
   $tmp_name = $_FILES["image"]["tmp_name"];
   $name = $_FILES["image"]["name"];
   move_uploaded_file($tmp_name, "$upload/$name", 0777);
James Njuguna
  • 604
  • 2
  • 12
  • 24