<!DOCTYPE html>
<script type="text/javascript">
function ShowFile(sFilePath){
    var oFileSystem = new ActiveXObject("Scripting.FileSystemObject");
    frmEditHTML.tarHTMLText.value = oFileSystem.OpenTextFile(sFilePath.value).ReadAll();

function SaveAfterEditing(sFilePath){
    var oFileSystem = new ActiveXObject("Scripting.FileSystemObject");
    var oFile = oFileSystem.CreateTextFile(frmEditHTML.filPath.value,1);

<form name="frmEditHTML">
Select the HTML File you want to Edit
<input type=file name="filPath" onchange="ShowFile(this)">
<textarea name="tarHTMLText" cols=60 rows=20></textarea>
<input type="button" value="Save" name="cmdSave" onclick="SaveAfterEditing(this.form['tarHTMLText'])">

This code helps to browse a file on a system an than loads its contents to the textarea and lets us to save the changes to that same file.
This code works only in Internet Explorer or in IE Tab in FireFox. I want to to do this without using ActiveX in PHP. HOw can I do this ??

Please Help!

Member Avatar


I want to to do this without using ActiveX in PHP. HOw can I do this ??

PHP runs on the server, while ActiveX runs on the client. I don't think you can.

Read more about it here regarding about Admin:


commented: To Rectify what some retard did to LastMitch +3

If I understood what you are trying to do, you'll have to do the following:

  1. Uplod the selected file to the server (using <input type="file" />).
  2. Read the file on the server and show in the text area.
  3. User edit the file and click save
  4. Send the edited text to the server
  5. The server will then either save the file to the disk and return the download link(like /editedtext.txt) OR it'll make a response to already download the text(using response headers like content-description and file-name, but I don't know exactly).

You could do only with the ActiveX that you have, but It'll only work on IE or browsers that thave ActiveX plugins, like Firefox.

Member Avatar

Ditto. You can't see files on the client via PHP. Javascript can't open files either - for good reason. Upload is probably the best method. This isn't as bad as it sounds, but you can't display the files in a local directory in the browser.