physaux Posted October 17, 2009 Share Posted October 17, 2009 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?? Quote Link to comment Share on other sites More sharing options...
landysaccount Posted October 17, 2009 Share Posted October 17, 2009 I beleive the /var/www/apache2/* directories should be owned by www-data user or user which apache or your webserver runs under. Quote Link to comment Share on other sites More sharing options...
Dorky Posted October 17, 2009 Share Posted October 17, 2009 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?? Quote Link to comment Share on other sites More sharing options...
Kaboom Posted October 17, 2009 Share Posted October 17, 2009 If a host try CHMOD the perms to 777 to make it writable? Or am i on the wrong idea here? Quote Link to comment Share on other sites More sharing options...
teynon Posted October 17, 2009 Share Posted October 17, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.