Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

drag and drop file upload

by raks_diamond (Initiate)
on Sep 20, 2013 at 09:54 UTC ( #1054988=perlquestion: print w/replies, xml ) Need Help??
raks_diamond has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys, I am new to cgi programming.I am given a task to implement the drag and drop file upload using blueimp jquery plugin.Now i am stuck on hook method.when i am dropping file on div flow goes to upload.cgi but hook method is not getting called as message i have put in hook method is not getting printed in log file.and size is being shown as 0kb. Same upload.cgi is used in the simple file upload from different pages of the project and i am getting log message for it and file is also getting uploaded. I have tried a lot but could not find the issue.CGI code is as follows:-

sub hook { &logMsg("In Hook1"); my ($name, $buffer, $bytesRead, $data) = @_; &logMsg("In Hook"); &logMsg("name=$name,bytesRead=$bytesRead"); if (defined $lastSeenName) { if (($name ne $lastSeenName) || ($bytesRead < $lastSeenTotal)) { $subTotal += $lastSeenTotal; } } else { $uploadSize = $ENV{'CONTENT_LENGTH'}; &logPct(0); } $lastSeenName = $name; $lastSeenTotal = $bytesRead; $fileSizeMap{$name} = $bytesRead; $totalBytes = $subTotal + $bytesRead; if ($uploadSize > 0) { my $curPct = int((100 * $totalBytes)/$uploadSize); $curPct = 98 if ($curPct > 98); &logPct($curPct); } } sub main() { readProperties(); $logFile = "/home/manish/files/temp1.log"; unlink $logFile; &logMsg("Main Method"); eval { mkpath($infoPath) }; if ($@) { &logMsg("Could not create $infoPath: $@"); $errorCode = "BAD_INFO_PATH"; } &processForm(); $ctSessionId = $paramMap{"ctSessionId"}; $uploadId = $paramMap{"uploadId"}; if (not (defined $uploadId)) { $uploadId = $ctSessionId; } if ($ctSessionId ne "0000") { &validateSession(); } &logMsg("before hook :: $ctSessionId :: $uploadId"); $cgi = new CGI(\&hook,"ctfile_upload"); $failureURL = $cgi->param('failureURL'); $successURL = $cgi->param('successURL'); my $queryParams = $ENV{'QUERY_STRING'}; $successURL = "${successURL}\?${queryParams}"; $failureURL = "${failureURL}\?${queryParams}"; my $action = $cgi->param('action'); if (defined $errorCode) { } elsif ($action eq "cancel") { $errorCode="CANCELLED"; } elsif ($action eq "overwrite") { $errorCode="OVERWRITE"; } elsif ($action eq "back") { $errorCode = "BACK"; } else { my $receiveError = $cgi->cgi_error; if ($receiveError) { &logMsg("Error receiving:$receiveError"); $errorCode = "NOT_RECEIVED"; } } if (-e "$tombstonePath/$uploadId") { $errorCode = "CANCELLED"; } if (defined $errorCode) { my @cgiParams = $cgi->param; foreach my $cgiParam (@cgiParams) { my @paramValues = $cgi->param($cgiParam); foreach my $paramValue (@paramValues) { &addField($cgiParam, $paramValue); } } } else { &logPct(99); &copyFiles(); &logPct(100); } if (defined $errorCode) { &logMsg("Error code = $errorCode"); &reportFailure(); } elsif (defined $recoverableErrorCode) { $errorCode = $recoverableErrorCode; &logMsg("Error code = $errorCode"); &reportFailure(); } else { &reportSuccess(); } }

Please help. Thanks, Rakesh

Replies are listed 'Best First'.
Re: drag and drop file upload
by Anonymous Monk on Sep 20, 2013 at 10:13 UTC
      Can you please explain how to use jQuery::File::Upload as i just have started in perl.I have already looked in to the jQuery::File::Upload but not able to use it properly.i have install it then used basic implementation(1'st example given on the web page of perl module) but still not get success. It would be helpful if you can help. Thanks, Rakesh

        Can you please explain how to use jQuery::File::Upload ?

        Sorry, no, statements like still not get success make me think I can't help you

        If its not doing what you want, explain how, explain how you're running what you're running, what is happening that is wrong, post any relevant errors/warnings/log message... troubleshooting, only you can troubleshoot your own mystery, and I already posted several links to get you up to speed

        More generic advice :) On debugging, verify everything, talk to teddybear ... checklists and more

Re: drag and drop file upload
by Laurent_R (Abbot) on Sep 20, 2013 at 16:08 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1054988]
Approved by Jim
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-07-25 07:45 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (364 votes). Check out past polls.