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

In reply to drag and drop file upload by raks_diamond

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.