Solved

PHP Warning: file_put_contents permission denied for directory

Posted on 2010-11-18
8
3,559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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
 
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

636 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