Hi,
 
I am trying to use Apache2::Request’s UPLOAD_HOOK feature to get client side upload progress bar using AJAX.  File upload happens correct but the UPLOAD_HOOK function is not being called. I thought in apache2/mp2 $r is a A2::RequestRec object and I should not be worrying about what is suggested here… http://www.masonhq.com/?LimitUploadFileSize  as I am creating a brand new A2::R object. Am I wrong there?  Can anybody guide me how to solve this?
   
  Server Configuration:
  Apache/2.0.55 (Win32)
  mod_perl/2.0.2 
  mod_apreq2-20051231/2.5.7
  HTML-Mason 1.32
   
  Code:
  
  #myPackage.pm
  package MyPackage;  
  use Apache2::Request;
  use Apache2::Upload;
  
  . . .
  sub hook {
    my ($upload, $data, $data_len, $hook_data) = @_;
    warn "$hook_data: got $data_len bytes for " . $upload->name;
  }
 
  . . . 
 
  #Upload.mhtml
  
 <%init>
  . . . 
  my $req = Apache2::Request->new($r, UPLOAD_HOOK => \&MyPackage::hook(),);
  my $uploadObj = $req->upload("inputFieldName");
  my $fh = $uploadObj->fh; 
  open OUTFILE, ">>$user_dir" or die;
  binmode OUTFILE; 
  while(<$fh>) {
              print OUTFILE $_;
  }
  close OUTFILE;
  . . .
 </%init>  
   
 
 
I also tried creating a sub for cgi upload using my $cgi_obj =  CGI->new(\&hook); as suggested in CGI docs but did not get much success there with the hook. Though upload is okay in both AR and CGI.
 
Thanks for your help in advance.
 
Vimal

 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to