On Thursday 26 February 2004 21:05, Paul Vudmaska wrote:
> Martin Hart wrote:
> >1. how can I tell whether or not the supplied parameter was a file upload
> > or simple text that has been passed to me as a Tempfile/StringIO?
>
> If it is just posted, its text. If you use enctype=multipart/form-data
> then all will be files.
> If you use the second, use $cgi['your_form_item'][0].read to get the
> text value.

that's not quite what I meant...  On a multipart form, is there a way to 
determine whether or not the value at $cgi["fred"] represents an uploaded 
file or just some text that was entered into an input control?

> >2. do hidden controls work with multi-part forms?  
>
> Yes. You'll need to access them as if they were a file -  like above.
>

ok I'll have to try this again - my previous tests led me to believe that 
$cgi["fish"] (where fish was a hidden control) returned me nil whatever the 
value of the control was.  I'll retest this.

> >3. why are all values expressed as Tempfile/StringIO when using a
> > multipart form?  Why not just have the file uploads as tempfiles?
>
> I've not used StringIO
>

I didn't think it was optional - is there a way to turn it off so that only 
Tempfiles are used?


Ruby-talk #19664 contains a patch that seems to offer what I want (i.e. 
representing only file uploads as objects of class Tempfile).  However that 
message is from Aug 2001 and things have moved on since then...

Can I ask if that patch was ever incorporated and if not why it was not 
suitable?  

It seems to me to be illogical and inefficient (assuming we have to create a 
load of tempfiles) to present all multipart form values as IO objects - 
surely it is better to just present the values that contain actual file 
uploads as IO objects?

Cheers,
Martin