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


In reply to Re: Re: About how PERL scripts execute by Eoin Redmond
in thread About how PERL scripts execute by Eoin Redmond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.