[SOLVED] fopen() permission denied error (IIS6 Server)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

[SOLVED] fopen() permission denied error (IIS6 Server)

Post by visitor-Q »

what is generally the source of this error?
[function.fopen]: failed to open stream: Permission denied

the error reported on the fwrite line:

Code: Select all

  $f=fopen("$filename", "w+");
  if ($f) {
   fwrite($f, $data);
   fclose($f);
   return 1
Last edited by visitor-Q on Wed Feb 21, 2007 10:45 pm, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP not having permission to open the file.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: fopen() permission denied error (IIS6 Server)

Post by RobertGonzalez »

visitor-Q wrote:what is generally the source of this error?
[function.fopen]: failed to open stream: Permission denied
Uh, generally you get permission denied errors when you are denied permission.
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

both posts were made by <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>... let me be more specific...

how do i fix this error? i tried checking the security properties for this file, and originally, it was only read and execute. but i changed the permissions and added write access to the file for random internet users. i restarted IIS, and it still won't work...

now, i know i do not have permission to open this file.... but WHY? and where would i change this feature??


next time, try not to be a dick.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

visitor-Q wrote:next time, try not to be a dick.
Insulting us for answering the specific question you asked is a great way to get answers to what you are actually asking. :roll:
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

feyd wrote:
visitor-Q wrote:next time, try not to be a dick.
Insulting us for answering the specific question you asked is a great way to get answers to what you are actually asking. :roll:
stating the obvious and being a dick is a great way of helping those who are trying to learn.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

visitor-Q wrote:
feyd wrote:
visitor-Q wrote:next time, try not to be a dick.
Insulting us for answering the specific question you asked is a great way to get answers to what you are actually asking. :roll:
stating the obvious and being a dick is a great way of helping those who are trying to learn.
I agree with feyd. Did you try google: http://www.google.com/search?hl=en&q=ch ... ns+PHP+777
That would give you this: http://www.trap17.com/index.php/change- ... 10082.html
Just use PHP to change it to 777 which is allow all.

Being nice can get you anwsers. :)
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

tecktalkcm0391 wrote:
visitor-Q wrote:
feyd wrote:Insulting us for answering the specific question you asked is a great way to get answers to what you are actually asking. :roll:
stating the obvious and being a dick is a great way of helping those who are trying to learn.
I agree with feyd. Did you try google: http://www.google.com/search?hl=en&q=ch ... ns+PHP+777
That would give you this: http://www.trap17.com/index.php/change- ... 10082.html
Just use PHP to change it to 777 which is allow all.

Being nice can get you anwsers. :)
thanks for your advice. unfortunately, that won't work. it is running on an IIS6 (microsoft) server (as the topic indicates). it does not respond to chmod. and i have already changed the permissions to the file manually (as mentioned in earlier posts) and that didn't work either.

of course i googled it. i never hit the forums until i've googled it. i didn't find much of anything beneficial. =\ i still don't know what to do here.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

visitor-Q wrote:i tried checking the security properties for this file, and originally, it was only read and execute. but i changed the permissions and added write access to the file for random internet users. i restarted IIS, and it still won't work...
Even though you are pretty rude ... have you tried to change the permissions on the folder containing the file, in addition to the file itself. The folder needs to be writable. I googled "php error [function.fopen]: failed to open stream: Permission denied on IIS6" and that's what most of links said to do.
(#10850)
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

arborint wrote:
visitor-Q wrote:i tried checking the security properties for this file, and originally, it was only read and execute. but i changed the permissions and added write access to the file for random internet users. i restarted IIS, and it still won't work...
Even though you are pretty rude ... have you tried to change the permissions on the folder containing the file, in addition to the file itself. The folder needs to be writable. I googled "php error [function.fopen]: failed to open stream: Permission denied on IIS6" and that's what most of links said to do.
yes, i should have mentioned i changed the folder permissions along with the file inside the folder.

as for being rude, i only treat others the way i am treated. i apologize for offending anyone. but all i was looking for was an apology from the beginning. you can't tell me that feyd and everah weren't being rude. i don't mind, just don't blame me if you find the taste of your own medicine bitter.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: fopen() permission denied error (IIS6 Server)

Post by RobertGonzalez »

You're question:
visitor-Q wrote:what is generally the source of this error?
[function.fopen]: failed to open stream: Permission denied
My answer:
Everah wrote:Uh, generally you get permission denied errors when you are denied permission.
Exactly how was that rude? Both feyd and I answered your question. You didn't ask how to fix it, you asked what caused it. We answered that. If you take the answer the wrong way because you didn't ask the question right, that is no one's fault but your own.

Now if you are looking for how to fix the problem... isn't there an IUSR of some sort that needs to be granted permissions at the server level? I think Burrito had this problem a few months ago. Try searching the boards for 'IIS* perm*', selecting 'Burrito' as the author and making sure to choose 'search all terms'.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

If you have php5 and the com extension installed try

Code: Select all

try {
	$service = new COM('winmgmts:'); 
	$sysobjects = $service->ExecQuery('SELECT * FROM Win32_ComputerSystem');
	foreach($sysobjects as $o) {
		echo $o->UserName, "<br />\n";
	}
}
catch(Exception $e) {
	echo 'Caught exception: ',  $e->getMessage(), "<br />\n";
}
// or
try {
	$net = new COM("WSCRIPT.Network");
	echo $net->UserName, "<br />\n";
}
catch(Exception $e) {
	echo 'Caught exception: ',  $e->getMessage(), "<br />\n";
}
The account that is printed needs file/ntfs permissions to write to $filename
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

thank you to everyone. apparently the problem stemmed from windows, and it's incredibely unstable environment. i made the permissions changes, and no effect took place. i restart IIS, and no effect took place, but when i checked the permissions, again, they changed back to unwritable file and folder. i changed it again] and then it worked =\.

but thank you for everyone's help. everah had a good point.
Last edited by visitor-Q on Thu Feb 22, 2007 11:29 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Glad you got it fixed.
Post Reply