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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.