Q:

How to code this ActiveX function in PHP? 

<! 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 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>

I read this link and this link but they could not help! 
I don't want to use ActiveX as then this function will be restricted to IE. 
IE Tab in FireFox is also causes problems! 
How can I replicate this whole function in PHP without using ActiveX ? 
Please Help! 

A:

Short answer:
With PHP you can't convert this script exactly as it is, since ActiveX is client side and PHP is server side.  Javascript can't do this for you either, since modern browsers are sandboxed, and JavaScript cannot access local file systems. 

Not so short answer:
You have other options, however, depending on which behavior (and implementation method) you wish to mimic. 
You can use a Java Applet that is able to do pretty much what you could do with ActiveX. Works consistently across browsers but user have to have installed Java Runtime Environment. 
You can use a mix of PHP + Javascript (AJAX).  You upload a file to the server and then control PHP actions with Javascript (HTTP Requests via Ajax). 

Hackish way
There is an hackish simple way to handle this situation.  Requires a server somewhere though.  

Create a page that uploads a file to the server. 
Then send the file back to the browser, via AJAX (or any request, doesn't matter). 
Manipulate the file in the client side (browser) with javascript. 
Give the file to the user to download.