Jscript To Upload File

[Total: 0    Average: 0/5]

This example uses Jscript (IE only) to upload a file.

Body Code:

You will need to set your action to your CGI file
<form name="the_form" method="post" action="http://www.js-examples.com/"> 
<input type="file" name="the_file" id="the_file">
<input type="submit" onclick="validateForm()"> 
<script language="JavaScript"> 
function validateForm() 
var fileaddress = document.the_form.the_file.value; 
<script language="JScript"> 
function uploadFile(fileaddress) 
var FSO; 
FSO = new ActiveXObject("Scripting.FileSystemObject"); 
// Reset fileaddress to contact this: 
fileaddress = FSO.OpenTextFile(fileaddress, 1); 
document.write("<input type="hidden" name="infofile" value="" + fileaddress.ReadAll() + "">."); 

Times Viewed: 5

Leave a Reply

Your email address will not be published. Required fields are marked *