Jump to content

Creating a file in php using linux


paulc8481

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/253484-creating-a-file-in-php-using-linux/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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