in reply to Passing database ID to \&hook through $data (CGI)
What you're trying to do is not what this was intended for, but you may be able to work around with QUERY_STRING
as long as action is /foo/bar.cgi?chicken=ididid QUERY_STRING will always contain your chickenmy $q = CGI->new($ENV{QUERY_STRING}); $data = $q->param('chicken'); $data = $1 if $data =~ //;# untaint chicken $q = CGI->new(\&hook, $data);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing database ID to \&hook through $data (CGI)
by k2OS (Initiate) on Sep 20, 2008 at 10:05 UTC | |
Then I do wonder what it was intended for then, if not for tracking the state of uploads. I made up a small example, using bits of your code: The upload-form: (form.html)
the upload-script: (minitest.cgi)
This leaves me with an empty file in uploads/ named '123456' and no log-file, meaning the hook wasn't called. I can only conclude, that the hook-feature makes it possible to either keep track of a specific upload by using un-sanitized filenames, giving me the option of actually using the progress-information logged by the hook, or using fully sanitized filenames in the hook as well, (by generating the ID within the upload-script, before declaring the cgi-obj), but then not having any posibilities of keeping track of the upload while it is in progress.. unless CGI.pm is modified so it will pass more information from the upload-handler. As I see it, the $data-option is nearly useless
Of course, if there is any other way of doing this in a nice way, don't keep it back :) | [reply] [d/l] [select] |
by Anonymous Monk on Sep 20, 2008 at 11:30 UTC | |
Nowhere is it suggested you can get your chicken before upload hook. It says The $data field is optional; it lets you pass configuration information (e.g. a database handle) to your hook callback. <!-- using GET will make the QUERY_STRING as mentioned in the previous post, but.. that's not how it's supposed to be? --> Who suggested you use get? I said as long as action is /foo/bar.cgi?chicken=ididid Example
| [reply] [d/l] [select] |
by k2OS (Initiate) on Sep 20, 2008 at 15:05 UTC | |
Dear Anonymous Monk, I was blind, but now I see. Of course it wasn't stated anywhere that should use GET, I guess I was just sleepy when I read your previous post. I did some more testing with your suggestion and lo and behold, it works like a charrm, so now I provide a fully working example*: (*Even though there are a few bits and pieces that should be checked up on (keeping things sane), I should remember to give credit to Justin Simoni, who posted the original script, on which this is based years and years ago)
Thank you to those who gave this some thought :) | [reply] [d/l] |
by Anonymous Monk on Sep 20, 2008 at 16:09 UTC | |
by k2OS (Initiate) on Sep 20, 2008 at 18:27 UTC | |