Mac
This might be of interest to you as I have now managed to get the upload file name into a Perl script before the upload starts. I know javascript is the devil but I couldn't see any another way. Merlyn has a script using fork and CGI:FileCache which looks promising but I couldn't
get it to run in a Win32 environment. Anyway, this is what I came up with:
First the form:
<form name="upload" action="filemngt_upload_file.pl" method="post" enc
+type="multipart/form-data" onSubmit="showProgress()">
Enter the name of the file to uploaded:
<input type="file" name="uploadfile" size="30">
<input type="submit" value="Upload File">
</form>
As you can see from the above I have added the javascript event handle onSubmit which runs a javascript function called showProgress(). When the submit button is pushed the onSubmit event handler is processed before the main submit function. Here is the code for the showProgress() function:
<SCRIPT LANGUAGE="JavaScript">
function showProgress() {
var uploadfilename = document.upload.uploadfile.value;
var newWindow = open("http://localhost/cgi-bin/test.pl?uploadfile=" +
+uploadfilename, "secondWindow", "scrollbars,resizable,width=250,heigh
+t=150,left=720");
}
</script>
Javascript allows you to access the name of the file for upload within a form. The line which begins with var = uploadfilename is where I'm setting a variable with the name of the file (which was entered by the user) for upload. I'm then opening a new window and calling a Perl script with the name of the file (to be uploaded) as a parameter.
So I now have 2 Perl scripts running, one uploading the file and the other running (in another window) which knows the name of the file which is being uploaded so I can now add code to it to start monitoring the upload
Hope this might be useful to you
Eoin
PS - All the above was tested (IE6) prior to this post |