I am trying to create a file outside of the public_html in php:
fopen("/home/sites/foo.org/backup-ticketing/asu.sql";w)
However I am getting this error message. I am sure I should be able to do it somehow I just can't figure it out. Permission of the folder is 711
.
[Wed Aug 01 14:33:54 2012] [error] [client 84.3.2.16] PHP Warning: fopen(/home/sites/foo.org/backup-ticketing/asu.sql) [function.fopen]: failed to open stream: Operation not permitted in /home/sites/foo.org/public_html/back/asu.php on line 4
Could you please advise me what is the right way to do please?
Thank you for the many advices now I have an additional info:
php.ini is the problem in public_html however I would like to keep it as it is but /back/ folder should be able to do so.
here is my settings:
file_uploads = Off
upload_tmp_dir = /var/php_tmp
upload_max_filesize = 0M
allow_url_fopen = Off
allow_url_include = Off
safe_mode = Off
display_errors = off
magic_quotes_gpc = off
magic_quotes_runtime = off
max_file_uploads=0
disable_functions=passthru,exec,phpinfo
open_basedir = /home/sites/foo.org/public_html/
It seems as PHP's Safe mode
or open_basedir are enabled preventing you from what you want to do - so it's simply not allowed and therefore not possible.
You could check if you are allowed to write to some other directory outside of your public directory, often ../tmp
or ../temp
are there and writable.
You might be able to find out what paths are allowed by open_basedir with
echo ini_get('open_basedir');
Another way around your problem: Put your files in a subdirectory of your public directory and secure it with .htaccess (User/Password, deny all IPs but your ow etc.)
EDIT:
Allow access only from certain IPs: Create a file and name it .htaccess with the content below
order deny,allow
deny from all
allow from 888.888.888.888
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With