0

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?

neufuture
  • 277
  • 3
  • 10
  • fopen under safemode requires that the directory you're running your script from is owned by the same UID as the UID the script is running under. Get your admins to change the ownership of the script to that of the webserver's – Marc B Apr 28 '11 at 17:29

4 Answers4

1

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.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
0

You can only open (and thus write) to files in directories, that are permitted by the safemode settings.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
0

You can use FTP.

Community
  • 1
  • 1
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

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.

http://php.net/manual/en/features.safe-mode.php

Shakti Singh
  • 84,385
  • 21
  • 134
  • 153