By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,002 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,002 IT Pros & Developers. It's quick & easy.

Permission denied when creating a file in PHP

P: 5
other interesting thing i observe during my work which i describe below:

i am using dotproject2.0.4 on fc3.
it is working fine.
but i want to generate pdf file report during this time i face permission denied problem.

Warning: fopen(/var/www/html/dotproject/files/temp/temp1.pdf): failed to open stream: Permission denied in /var/www/html/dotproject/modules/projects/reports/tasklogs.php on line 307
Could not open file to save PDF.

when i run below test php file using command line it will create file at particular location.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $file = fopen("/var/www/html/dotproject/files/temp/test.txt","w");
  3. print $file;
  4. $file1 = fopen("/var/www/html/dotproject/files/temp/test1.pdf","wb");
  5. print "hai $file1";
  6. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]


but when i run this php file in web browser it would not create file.

as i conclude it is problem with related to permission for user.

bec when i run from command line it runs with the permissions of the user who started the script means root if i login as root user.

but from web browser it runs as web browser user.

in my httpd.conf file user and group is as follow

User Apache
Group Apache


how to set permission so web browser user also can access file and create file.

i have change all directory permission to 777 and also test file permission.

/var/www/html/test/

but still it will not working.

it resolves my many issue related to permission.

is there any other issue?


thanks in advance
Jun 29 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'problem' actually get FEWER responses?).
Jun 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.