My PHP script creates to some file to ensure that it can produce a digital image.

fwrite($handle, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($handle);    
print $newfile.'.jpg';

I've put this script on the new server nevertheless the image never will get saved. The permission from the folder it saves to is 755 but it doesn't purchased it. Before, I believe I fixed the problem by altering your directory owner to apache because this is what PHP runs as. I am unable to perform the same again because I'm not root.

First of all., Can there be another fix? Next, Basically could change who owns your directory like before will this fix the problem?

Thanks all for just about any help

  1. change permissions from the folder to 777 (rwxrwxrwx)
  2. from PHP create subdirectory with mkdir
  3. improve your directory permissions to 755 (rwxr-xr-x) as well as 711 (rwx--x--x)
  4. to any extent further save your valuable images within the subdirectory, that is now possessed by www-data (or whichever user Apache uses).

BTW. you are able to reduce following code:

fopen($newfile.'.jpg','wb');
fwrite($handle, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($handle);    
print $newfile.'.jpg';

to:

file_put_contents($newfile.'.jpg', 
                  file_get_contents('php://input', 
                                      FILE_BINARY), 
                  FILE_BINARY)

If you are not the dog owner, then yes, your directory being 755 is a concern.

To interrupt it lower, 755 is:

  • user (owner) has read (4), write (2), and execute (1)
  • group has read (4) and execute (1)
  • others read (4) and execute (1)

Observe that only the dog owner has write rights with 755.

P.S. fopen should return a mistake when the open unsuccessful.

I'd an identical problem a few days ago. It wound up being the PHP safe mode occur the server.

Make sure that out!

Put error_confirming(E_ALL) towards the top of your script and appearance whether it prints out any alert while attempting to save a picture.