peted Posted March 14, 2007 Share Posted March 14, 2007 Hi - I'm having an issue with fopen, in that it doesn't work for the following code: <? mkdir("/data/websites/www/about/try/", 0777); $fp = fopen("/data/websites/www/about/try/test.php", "w"); fwrite($fp, "test"); fclose($fp); ?> the mkdir works fine and creates the folder, but the file "test.php" is not created. Any ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/42663-help-a-noob-fopen-problem/ Share on other sites More sharing options...
flappy_warbucks Posted March 14, 2007 Share Posted March 14, 2007 Try: <? $dir = "/data/websites/www/about/try/"; mkdir("$dir", 0777); $fp = fopen("$dir/test.php", "w"); fwrite($fp, "test"); fclose($fp); ?> Look at your code it should work dont see why it dont ??? Link to comment https://forums.phpfreaks.com/topic/42663-help-a-noob-fopen-problem/#findComment-206987 Share on other sites More sharing options...
per1os Posted March 14, 2007 Share Posted March 14, 2007 $fp = fopen("/data/websites/www/about/try/test.php", "w+"); fwrite($fp, "test"); fclose($fp); Adding the plus should create the file, without the plus it assumes y ou are trying to open an existing file where if you just made the directory I bet it is empty. Link to comment https://forums.phpfreaks.com/topic/42663-help-a-noob-fopen-problem/#findComment-207569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.