I would love to know if any body has a knowledge of opening a file like a html or a css file on the server and edit the file, after editing, perform a save on the file.
Example like in joomla where one can open the html pages in a textbox and edit the file and save the file again.
I would love to know how this could be done in php
Any help will realy be appreciated.
PHP can open and save a file (file_get_contents(), file_put_contents()) but editing you have to do yourself. and since PHP is not an editor, you have to pass the data to an application that can handle the editing.
Thank you very much for the snippet but how ever i am a little confused on how to go about this.
Example i have a page called test.php on the same diretory as my current php page, i would like to output it in a texteditor and when i edit the outputed content and submit the form how do i write my php code to save the new file using the same mane as test.php in the same directory. thank you very much.
that#s quite simple. when you send the edited content back to PHP, you get the sent string via GET/POST and (after verifying that the content is trustworthy) you can save it to disk. you can send the filename with this form as well so you don’t have to lock your application.
personally, I recommend to allow this only for logged in users, otherwise everyone could edit files on your server.
okay i tried file_get_content its only displaying the body part of the html code. I would like it to show the source code too including the scripts and head tags. heres my sample php code
$t = file_get_contents('mypage.html');
<textarea><?php echo html_entity_decode($t); ?></textarea>
<input type="submit" Value="submit" />
I would like the whole page content including the doctype,html,head,title and scripts tags to display in the textarea.
I appreciate it
var_dump($t) give you?
Hey thank you soooooooooooooooooooooooo much i found that very helpful
I appreciate it.