Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP Warning: file_put_contents permission denied for directory

Posted on 2010-11-18
8
Medium Priority
?
3,682 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

721 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