...

View Full Version : on-site text/file editing.



Shecky
03-13-2003, 04:12 PM
When it comes to php i'm a real lightweight, and the only experience i've had with it up till now was with mysql. I'm helping my friend out with his site but it doent have a mysql database.

SO i made these include files for him that mostly have detailed instructions on how to modify an array to update his site... he still doesnt get it... and ftp kinda scares him.

So, to get to the point, (finally,) i'm making a webpage where he can just upload his (for example) image files, and i was wondering what a good way to have these automatically entered into the array of photos to display. (that array i mentioned, sitting by itself in an include file)

that probly seem extremely simple... also i need to know how i can load a text based file into a text area input field, that, when submitted will replace the old file with the updated/submitted one :)

you could probly just call toss me a couple of funtion names... i know where php.net is :) but if you want to be my hero, you slap some stuff together :-P

_shecky

x_goose_x
03-13-2003, 10:09 PM
edit file:


<?php

$filename = "file.php";

$txt = $_POST['txt'];

if ($txt) {
$fpw = fopen ($filename, "w");
if (!fwrite($fpw, urldecode($txt))) {
print "Unable to write to file";
exit;
}
fclose($fpw);
}

if (file_exists($filename)) {
$fpr = fopen ($filename, "r");
$content = fread ($fpr, filesize ($filename));
fclose($fpr);
}

?>

<form method="POST">
<textarea rows="15" cols="80" name="txt"><?=$content?></textarea>
<input type="submit" value="Update File">
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum