paulc8481 Posted December 19, 2011 Share Posted December 19, 2011 I am new to Php and the linux environment. I have written a php program which sames a file to folder using xampp in Windows but I am having a problem with the pathway using my Ubuntu server and LAMP. My code I used in Windows was: $fileName = "guessbook.txt"; $file = fopen ($fileName, "ab"); if(!$file) { echo "ERROR! did not create the file! Exiting.<br />; exit(); } This file was saved correctly using xampp into the htdoc folder and worked fine when I called it in my browser. I tried to substitute a Linux pathway ie: /var/www/assignment2/guessbook.txt, where guessbook is in the code but still nothing. Can someone explain how to write the correct pathway to save this file? Thank you Paul Quote Link to comment https://forums.phpfreaks.com/topic/253484-creating-a-file-in-php-using-linux/ Share on other sites More sharing options...
scootstah Posted December 19, 2011 Share Posted December 19, 2011 You don't need to write the absolute path, just write it relative to the file saving it. And make sure you have permission to create files in that directory. Quote Link to comment https://forums.phpfreaks.com/topic/253484-creating-a-file-in-php-using-linux/#findComment-1299378 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.