rocku has asked for the wisdom of the Perl Monks concerning the following question:

Hi, sorry for my bad English. I've designed an upload progress bar using AJAX and the CGI.pm's hook functionality. Basicly, the hook is writing a percent of progress to a temp file and another script called by AJAX is reading this file. Suddenly when everything started to work I've came up with the problem of how to determine which user is currently uploading (since there is only one temp file). An ideal solution would be to pass a query parameter with an ID to the hook. But as I scoped through google and CGI's doc, it seems impossible since the hook functions reference and all it's parameters need to be declared when creating a CGI object. Please, prove me wrong.
  • Comment on CGI.pm, passing query params to upload hook

Replies are listed 'Best First'.
Re: CGI.pm, passing query params to upload hook
by atemon (Chaplain) on Aug 13, 2007 at 04:28 UTC
      Hi!
      Thanks for a quick reply. Somehow I've missed Understanding CGI::upload_hook(), the example shown there did give me a hint how to solve my problem. I've set a cookie with the ID and read it before creating the query object. Here is my code:
      sub get_cgi_query { my %cookies = CGI::Cookie->fetch; my $hook_id = $cookies{CGISESSID}->value unless !defined($cookies +{CGISESSID}); if (defined($hook_id)) { return CGI->new(\&hook,$hook_id); } else { return CGI->new(); } }