0

I use one script to create a folder on the server using PHP, like so:

mkdir("folder/test/", 0777);

Then I use another script to create a file and put some contents into it, like so:

fwrite( fopen('folder/test/filename', 'w'), 'Test text' );

This, however results in:

Warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is XXXXX is not allowed to access ...

If, however, I try to create the file in the parent directory, like so:

fwrite( fopen('folder/filename', 'w'), 'Test text' );

it works fine. The parent folder ('folder' in the above example) is set to 777 'manually', so the 'SAFE MODE Restriction' only appears when I first create a folder using mkdir and then try to write in the same folder. How can this be?

Matte
  • 279
  • 6
  • 16
  • What owner:group does the new folder have? – Louis Huppenbauer Sep 20 '12 at 08:45
  • Check the permissions on the test folder.Mght be that SAFE MODE does not allow you to mkdir a dir with 777 permissions.[This](http://stackoverflow.com/questions/3997641/why-cant-php-create-a-directory-with-777-permissions) might help. – Vlad Sep 20 '12 at 08:47
  • Um.. how do I check? Actually looking at the permissions in terminal shows dr-xr-xr-x for the newly created folder, seems like PHP doesn't follow orders and set it to 777 as in the script. Might this have something to do with the SAFE MODE-issue? – Matte Sep 20 '12 at 08:52
  • @VladTeodorescu Good tip, tried it out, and the permissions for the folder are now: drwxrwxrwx. However the SAFE MODE restriction still appears... Any ideas? – Matte Sep 20 '12 at 09:00

1 Answers1

1

according to the manual safe mode has been deprecated as of php 5.3.0. try upgrading your php version or turn safe mode off in php ini

depz123
  • 497
  • 5
  • 18
  • That would be a great idea, but as I'm not the owner of the server this is not an option. I'm looking for a work around running the current version (5.1.6). (Believe me, I've tried to convince them to upgrade before with no luck so far...). – Matte Sep 20 '12 at 09:32