Martin Hart wrote:

>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?
>
>  
>
No, not as far as i know(which is not very far!!)

>>>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.
>  
>
They seem to work. I tested it.

>  
>
>>>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
>>
>>    
>>
Sorry, i dont know!

>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...
>
>  
>
The version I use (on my host) is 1.6 or so

>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
>
>
>  
>
Seems like a good questions but I honestly dont know.

When things are sent with multipart/form-data the items are actually 
sent as a sort of  binary form(to support say,gif files). And it is the 
responsibility of  the server side code to disect it.

So, the fields are either all binary or all text.

But hey, i'm pretty new so keep that in mind :)
Paul