0
<!DOCTYPE html>
<html>
<head>
<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);
    oFile.WriteLine(sFilePath.value);
    oFile.Close();
}
</script>
</head>

<body>
<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'])">
</form>
</body>
</html>

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!

4
Contributors
3
Replies
5
Views
4 Years
Discussion Span
Last Post by diafol
8

@apanimesh061

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:

http://technet.microsoft.com/en-us/library/dd346861.aspx

Edited by LastMitch: grammer

Votes + Comments
To Rectify what some retard did to LastMitch
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.