Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3792
  • Last Modified:

PHP Warning: file_put_contents permission denied for directory

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
gfei
Asked:
gfei
  • 4
  • 4
1 Solution
 
schwompCommented:
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
 
gfeiAuthor Commented:
I will resume this on Monday at the office. I will update when I can get on my computer there. Thanks in advance.
0
 
schwompCommented:
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.

 
gfeiAuthor Commented:
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
 
schwompCommented:
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
 
gfeiAuthor Commented:
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
 
gfeiAuthor Commented:
This solution would help someone who did not have an issue with IIS permissions. So, I will award the points to the responder.
0
 
schwompCommented:
> 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now