galvin Posted September 22, 2010 Share Posted September 22, 2010 I have fopen() code that works fine.. $filename = "trade.php";$filehandle = fopen($filename, 'w') or die("can't open file");fclose($filehandle); But I want it to create the file "trade.php" in a specific directory called "tradepages". I tried changing the one line to be... $filename = ".../tradepages/trade.php"; But that just gives an error saying no such directory exists (even though it definitely does). There has to be a way to create files in whatever folder/directory you want, right? Anyone know how, or what I'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/214120-how-to-fopen-into-a-specific-directory/ Share on other sites More sharing options...
ngreenwood6 Posted September 22, 2010 Share Posted September 22, 2010 Try this: $filename = $_SERVER['DOCUMENT_ROOT']."/tradepages/trade.php";$filehandle = fopen($filename, 'w') or die("can't open file");fclose($filehandle); This is assuming that /tradepages is right off the root of the server if not you will have to adjust. Link to comment https://forums.phpfreaks.com/topic/214120-how-to-fopen-into-a-specific-directory/#findComment-1114176 Share on other sites More sharing options...
galvin Posted September 22, 2010 Author Share Posted September 22, 2010 Worked perfectly, ngreenwood6! Thanks a lot!!!! Link to comment https://forums.phpfreaks.com/topic/214120-how-to-fopen-into-a-specific-directory/#findComment-1114178 Share on other sites More sharing options...
ngreenwood6 Posted September 22, 2010 Share Posted September 22, 2010 np Link to comment https://forums.phpfreaks.com/topic/214120-how-to-fopen-into-a-specific-directory/#findComment-1114180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.