Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

CGI file upload/param passing

Quote Reply
CGI file upload/param passing
Alex,

Just want to check:

If in a pre-processing routine, I do:

my $in = $IN->get_hash();

$in is now a reference to the hash of values, and I can pass $in, rather than having to access $IN->param() in lower level routines, correct?

I know we fixed a bug in this earlier, but I wasn't trying to pass it down the line, just use the reference, rather than the object->param().

It would probably be better in the long run, to put the uploads into an object, then operate on those objects, but I need an intermediate step or two before that.

If my $in hash now contains a hash:

{ mis_keys => misc_values, File_1 => file1_buffer, File_2 => file2_buffer, ...}

this is passed, and accessible via the hash reference, not the object reference with param.
If I take the uploaded file, and stuff it into an Upload object, I gain a lot of advantages.

The big thing is being able to pass $in, rather than have a routine try to look at $IN.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: CGI file upload/param passing In reply to
Hi,

Well, technically $in is a copy, not a reference. So if you change $in, it won't affect what $IN->param() would give you.

Also, a side effect of ->get_hash() is any filehandles (i.e. upload fields) get clobbered, and you only have the filename available. You would need to call $IN->param('upload_field') again.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: CGI file upload/param passing In reply to
In Reply To:
Also, a side effect of ->get_hash() is any filehandles (i.e. upload fields) get clobbered, and you only have the filename available. You would need to call $IN->param('upload_field') again.
That is what I was afraid of...



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin