I can't use fopen because PHP is in safemode and admin wont change this. How can I write a static html file using php?
4 Answers
With difficulty, unfortuantely. If your sysadmin has not set up user permissions that allow you to do this, then there's no general workaround. Other answers (e.g. FTP-ing) may work in certain circumstances (again, if user permissions allow it).
The only foolproof solution is to talk to the sysadmin.

- 267,707
- 33
- 569
- 680
-
@Robert: My previous answer was meant in all seriousness. But I've expanded upon it now. – Oliver Charlesworth Apr 28 '11 at 17:37
You can only open (and thus write) to files in directories, that are permitted by the safemode settings.

- 128,817
- 21
- 151
- 173
-
Yes, if the FTP server has write permission to the directory in question. – Oliver Charlesworth Apr 28 '11 at 17:29
You can still do with safe mode enabled
Beware: Safe mode will not permit you to create new files in directories which have different owner than the owner of the script. This typically applies to /tmp, so contrary to Unix intuition, you will not be able to create new files there (even if the /tmp rights are set correctly).
If you need to write into files in /tmp (for example to put logfiles of your PHP application there) create them first on the command line by doing a
touch /tmp/whatever.log
as the same user who owns the PHP script. Then, provided the rest is configured correctly, the PHP script will be able to write into that file.

- 84,385
- 21
- 134
- 153