News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

PHP Upload Script Help

Started by tsb, December 12, 2003, 06:28:25 AM

Previous topic - Next topic

tsb

I'm using the following code at the moment to try and create a script to edit an already uploaded file and save, but it's not displaying the file at all, but i know the path is correct. The textarea box is just blank, and i have CHMODed the file.php to 666. Any help would be very useful...

<?php
$file 
"/home/sites/site10/web/file.php";
$fs fopen$file"a+" ) or die("error when opening the file");

while (!
feof($fs)) {
   
$contents .= fgets($fs1024);
}

fclose($fs);
?>


<html>
<head>
<title></title>
</head>
<body>
<form action="save.php" method="post">
<input type=hidden name="file" value="<?php echo $file?>">
<textarea name="contents"><?php echo htmlspecialchars($contents); ?></textarea>
<input type="submit" value="Submit">
</form>
</body>
</html>


The save.php file is:

<?php
$fs 
fopen$_POST["file"], "a+" ) or die("error when opening the file");
fwrite($fs$_POST["contents"]);
fclose();
?>

Advertisement: