Page 1 of 1

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

Posted: Wed Feb 21, 2007 1:57 pm
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

Posted: Wed Feb 21, 2007 2:20 pm
by feyd
PHP not having permission to open the file.

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

Posted: Wed Feb 21, 2007 2:25 pm
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.

Posted: Wed Feb 21, 2007 3:04 pm
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.

Posted: Wed Feb 21, 2007 3:56 pm
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:

Posted: Wed Feb 21, 2007 4:22 pm
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.

Posted: Wed Feb 21, 2007 4:46 pm
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. :)

Posted: Wed Feb 21, 2007 4:52 pm
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.

Posted: Wed Feb 21, 2007 5:15 pm
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.

Posted: Wed Feb 21, 2007 5:41 pm
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.

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

Posted: Wed Feb 21, 2007 6:20 pm
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'.

Posted: Wed Feb 21, 2007 7:31 pm
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

Posted: Wed Feb 21, 2007 10:43 pm
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.

Posted: Thu Feb 22, 2007 11:03 am
by RobertGonzalez
Glad you got it fixed.