Solved

PHP Warning: file_put_contents permission denied for directory

Posted on 2010-11-18
8
3,334 Views
Last Modified: 2013-11-19
I am about to pull my hair out on this issue. I have written a mail checking script which checks our mail server (hosted remotely) and it needs to download attachments and copy them to a directory on my local intranet web server.

The script is properly going through mail, the problem is the attachments. I cannot seem to gain permissions to the directory to create a file there.

Here is the error I am getting:

PHP Warning: file_put_contents(scans/10-4194.txt) [function.file-put-contents]: failed to open stream: Permission denied in C:\inetpub\wwwroot\quotation_test\log\log_mailcheck.php on line 107

I am running IIS 7 and PHP 5.2

Safe modes in PHP are already turned off (I heard this could cause issue). I have already go into Windows via IIS and the Explorer to check the Permissions for the "scans" directory. IIS_IUSERS is set to Allow for everything.

What could I be missing? Thanks in advance.

Jen
0
Comment
Question by:gfei
  • 4
  • 4
8 Comments
 
LVL 2

Expert Comment

by:schwomp
ID: 34167306
Hello!

Check your open_basedir directive in php.ini.

Does the directory C:\inetpub\wwwroot\quotation_test\log\scans exists ?

Maybe it could be easier to find a solution if you post your code, . ;)

Bye.
0
 

Author Comment

by:gfei
ID: 34168785
I will resume this on Monday at the office. I will update when I can get on my computer there. Thanks in advance.
0
 
LVL 2

Expert Comment

by:schwomp
ID: 34170958
You welcome!
0
 

Author Comment

by:gfei
ID: 34188299
Okay, I am back in the office.

open_basedir is commented out in PHP.INI file. Should this be changed?

This is the line of code I am using as test line to see if I can at least get the function working:

file_put_contents("scans/".$fileName.".txt", "test data");

and it returns this error:
PHP Warning: file_put_contents(scans/10-4194.txt) [function.file-put-contents]: failed to open stream: Permission denied in C:\inetpub\wwwroot\quotation_test\log\log_mailcheck.php on line 107

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Accepted Solution

by:
schwomp earned 500 total points
ID: 34191815
Hum....

var_dump ( is_writable ( "scans/" ) );

if it returns false, you have a permission problem with the directory.

Try a chmod ( "scans/", 777 );

Bye.
0
 

Author Comment

by:gfei
ID: 34192795
All right, schwomp, I will give you the points because in theory, your answer was correct and will probably help someone. That directory was not writable. I am not sure if that chmod command would have fixed it though.

The problem was more in-depth and required a permissions reset of the directory in IIS, along with giving the directory permissions using the Security tab in Windows.
0
 

Author Closing Comment

by:gfei
ID: 34192802
This solution would help someone who did not have an issue with IIS permissions. So, I will award the points to the responder.
0
 
LVL 2

Expert Comment

by:schwomp
ID: 34194403
> The problem was more in-depth and required a permissions reset of the directory in IIS, along with giving the directory permissions using the Security tab in Windows.

Sorry, I did not pay attention to the fact that you were using Windows...

nevertheless, thanks for the points!

Bye
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now