http://www.perlmonks.org?node_id=998757

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I would like to upload file using Ajax+Perl. I am not able to send data to server using Ajax.
Can anyone please help me to upload file content to Perl program using Ajax.
Here is my HTML code
<html> <head> <title> New Document </title> </head> <script type="text/javascript"> <!-- function UploadStatus() { var xmlhttp; if (window.XMLHttpRequest) {// It will support IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// It will support IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("statushere").innerHTML=xmlhttp.responseTe +xt; } } xmlhttp.open("POST","../cgi-bin/upload.pl",true); xmlhttp.send(); } //--> </script> <body> <h1>Upload Form</h1> <form enctype="multipart/form-data"> <center> Enter a file to upload: <input type="file" name="upfile"><br> <input type="button" name="button" value="Upload File" onclick="Upload +Status()"> </center> <div id="statushere" align="center"></div> </form> </body> </html>
Thanks