Jump to content

PHP and .txt files


Recommended Posts

Hello,

 

I have a PHP script which updates a .txt file on my server with new text for a page on my website. Im using CuteFTP to upload files. I had been able run my PHP script from one folder using a windows server, but when i moved it to another folder supported by a linux server it wouldn't run. I know i need to change the permissions of the .txt file to 777 which i have done but the script stil will not run..

 

<?php
$loadcontent = "innertext.txt"; 
if($save_file) {
$savecontent = ($savecontent);
$fp = @fopen($loadcontent, "w");
if ($fp) {
fwrite($fp, $savecontent);
fclose($fp);
}
}
$fp = @fopen($loadcontent, "r");
$loadcontent = fread($fp, filesize($loadcontent));
$loadcontent = htmlspecialchars($loadcontent);
fclose($fp);

?>

<form method="post" action="<?=$_SERVER['PHP_SELF']?>" name="savecontent">
<textarea name="savecontent" cols="70" rows="25"><?=$loadcontent?>
</textarea>
<input type="submit" name="save_file" value="Save">  
</form> 

Link to comment
https://forums.phpfreaks.com/topic/64823-php-and-txt-files/
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.