1

I'm trying to create a file in a directory outside the document root of the web server. The folder has permissions 777 but php says Permission Denied: Warning: fopen(/home/site2/public_html/images/x.jpg) [function.fopen]: failed to open stream: Permission denied in /home/site1/public_html/test_sites.php on line 2 Permission problem

<?php
$f = fopen('/home/site2/public_html/images/x.jpg', 'wb');

if(!$f) die("Permission problem");

fclose($f);
echo "OK";
?>
1
  • public_html doesnt sound exactly like it is outside document root. Also you do not want any folders to be world writable (777) unless you want your security to go to 666. Commented Jul 22, 2010 at 21:52

2 Answers 2

2

The 777 permissions is half the battle. You will also need to change the group to be www-data (if on debian) using the:

chgrp g+w www-data /home/growtent/public_html/images

That "should" work, depending on what system you are running and given that my memory is correct.

Sign up to request clarification or add additional context in comments.

Comments

0

It sounds like safe mode is on and doc_root has been set. You'll need to set doc_root to empty or turn off safe mode.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.