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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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