Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Perlhtml> <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>
Thanks for the Help!!#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Upload with JQuery
by marto (Cardinal) on Dec 08, 2010 at 15:12 UTC | |
by Anonymous Monk on Dec 08, 2010 at 15:22 UTC | |
by marto (Cardinal) on Dec 08, 2010 at 15:30 UTC | |
| |
|
Re: Perl Upload with JQuery
by ww (Archbishop) on Dec 08, 2010 at 18:51 UTC | |
by Anonymous Monk on Dec 08, 2010 at 19:11 UTC |