Jump to content

fopen(___.txt) [function.fopen]: failed to open stream: Permission denied. help!


physaux

Recommended Posts

My error:

Warning: fopen(NameFile_dogs.txt) [function.fopen]: failed to open stream: Permission denied in /Users../Sites/nametest/index.php on line 43
can't open file

 

Here is the relevant code:

<?php
//...
$DirectionsFile = "NameFile_".$species.".txt";
$fh = fopen($DirectionsFile, 'w') or die("can't open file");  // THIS IS LINE 43
//...
fwrite($fh, "Scrubs\n");
fwrite($fh, "Snoopy\n");
//...
if(isset($fh)){
fclose($fh);
}
?>

 

Anyone know how to fix this? I have no clue how to set/vary php/other permissions for my files. Also it is the first time i tried this code, so i know the filename does not exist yet.

 

Other than that, i'm lost! Any1 have a clue??

are you on a host or your own server?

My error:

Warning: fopen(NameFile_dogs.txt) [function.fopen]: failed to open stream: Permission denied in /Users../Sites/nametest/index.php on line 43
can't open file

 

Here is the relevant code:

<?php
//...
$DirectionsFile = "NameFile_".$species.".txt";
$fh = fopen($DirectionsFile, 'w') or die("can't open file");  // THIS IS LINE 43
//...
fwrite($fh, "Scrubs\n");
fwrite($fh, "Snoopy\n");
//...
if(isset($fh)){
fclose($fh);
}
?>

 

Anyone know how to fix this? I have no clue how to set/vary php/other permissions for my files. Also it is the first time i tried this code, so i know the filename does not exist yet.

 

Other than that, i'm lost! Any1 have a clue??

I'm assuming you are running windows. Windows does not use file permissions. If you are getting a file permission error, it is possible that the directory does not exist and you need to create it.

 

if (!is_dir($dir)) { // create the directory first }

 

Also, if you didn't install php / apache as administrator that could cause issues

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.