Jump to content

[SOLVED] File is wiped blank when opened with fopen()


elite_prodigy

Recommended Posts

I'm using the following to open a file:

 

<?php

$local = "overall.css";
$css_file = fopen($local, "w+");
$CSS = fread($css_file, 400000);
fclose($css_file);
?>

 

The following is supposed to display the output:

 

<textarea name="css" rows="35" cols="75" wrap="virtual"><?php echo $CSS; ?></textarea>

 

But, everytime I view the page that opens and reads the file, the file is empty! I don't think I'm doing anything wrong, but obviously something isn't working right.

 

Can someone please help me?

Link to comment
Share on other sites

are you running the scrip in the same directory as the file "overall.css" is stored?  It could be that the script is not really find the file you think you're looking for and is showing a new, blank page.  perhaps you could try the full path to the file.

 

$local = "/var/www/mywebsite/path/to/overall.css";

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.