Page 1 of 1
How to Open & Edit file in List Content of Directory.
Posted: Sat Dec 07, 2013 7:36 am
by bhb
Hello Everyone, I’m having a page php have function list content of directory in computer such as c:/folder after that I can open, write and save any file I want in list file. Now I have complete to list content of directory, now I want to click any file in list file of derectory to open in a textarea under list content of drictory to view and edit file, then I have a button submit to save it. I don’t know how to do it so please fix my code I give under introduce me some example demo code or document to reference. Please help me. Thank very much.
Here is my code:
https://www.mediafire.com/?19123qkmgmf7toj
Example picture about page equivalent and similar:
In this picture it have list file.

Now we can click to open 1 file such as “extensions.conf” to read, write and save it by button submit (update)

Re: How to Open & Edit file in List Content of Directory.
Posted: Sat Dec 07, 2013 11:05 am
by bhb
Who known ? Please give me some answer?
Re: How to Open & Edit file in List Content of Directory.
Posted: Sat Dec 07, 2013 11:28 am
by Celauran
I'm not going to download some random mediafire link, and I doubt anyone here will either. Post the relevant parts of your code and we'll see what we can do.
Re: How to Open & Edit file in List Content of Directory.
Posted: Tue Dec 17, 2013 11:33 am
by bhb
I still don't know how to when I click to file name in list content of directory, it content have show in textarea, what event click to to it ? I have read a example simple below but it open and save file have direct directory.
Code: Select all
<?php
$filename = isset($_GET['file']) ? $_GET['file'] : '';
$directory = ("c:/folder/file.php"); // Restrict to this directory...
$fn = $directory . $filename;
if (isset($_POST['content']))
{
$content = stripslashes($_POST['content']);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<textarea rows="25" cols="100" name="content"><?php readfile($fn); ?></textarea>
<hr />
<input type="submit" value="Save">
</form>
Here is my
https://www.mediafire.com/?l3go25zl88359zu
Re: How to Open & Edit file in List Content of Directory.
Posted: Mon Dec 23, 2013 5:43 am
by stanliwise
I think you should read more on php file manger function e.g scandir(); or DirectoryIterator() function.
Scandir give an array list of files in folder.
While the latter do the same and even more.
After read it.
Just try to loop the function in an html <select><option></option></select> tags.
I am waiting for your reply.