Hi Monks!
I found this code here and it supposed to do what I am looking for, but I can not get it to work at all. Anyone here got it to work or have any better example?
Here is what I have: I have jquery-1.2.6.js downloaded
HTML
html> <head> <!--jquery should be included before any other js--> <script type="text/javascript" language="javascript" src="jquery/jquer +y-1.2.6.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#file").change(function() { $("#form1").submit(); }); }); function callback(msg) { $("#msg").html(msg); } </script> </head> <body> <form action="../cgi-bin/ajax_upload.pl" id="form1" name="form1" encty +pe="multipart/form-data" method="post" target="hidden_frame" > <input type="file" id="file" name="file" style="width:450"> <INPUT type="submit" id="test" value="submit"> <span id="msg"></span> <br> <iframe name='hidden_frame' id="hidden_frame" style='display:none'></i +frame> </form> </body> </html>
Perl
#!/usr/bin/perl use warnings; use strict; use CGI; my $form = new CGI; print $form->header; #Print HTML header. this is mandatory #my $web_home = "$ENV{DOCUMENT_ROOT}/ajax_files"; my $web_home = "../../ajax_files"; my $UPLOAD_FH = $form->upload("uploadfile"); my $newfilename = "new_file"; umask 0000; #This is needed to ensure permission in new file open my $NEWFILE_FH, "+>", "$web_home/tmp/$newfilename.txt" or die "Problems creating file '$newfilename': $!"; while ( <$UPLOAD_FH> ) { print $NEWFILE_FH "$_"; } close $NEWFILE_FH or die "I cannot close filehandle: $!"; ##this is the only way to send msg back to the client print "<script>parent.callback('upload file success')</script>"; exit;
Thanks for the Help!!

In reply to Perl Upload with JQuery by Anonymous Monk

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.