
stephen at enterity
Jan 24, 2010, 7:44 AM
Post #3 of 15
(2166 views)
Permalink
|
I believe your problem lies in the browser itself. I know, for example, that browsers do not send empty values for checkboxes that remain unchecked - they simply eliminate that field from the form submission altogether. Sounds like file fields might be the same way. Your best bet is to use a bit of scripting on the browser side to mark a hidden field to stand in for the empty file field. - Stephen On Jan 24, 2010, at 7:03 AM, Octavian Rasnita wrote: > Hi, > > After sending a form with a file upload field, that field is lost if > no file > was attached, just like when the form doesn't contain that file > upload field > at all. > > I have tried to check Catalyst, Catalyst::Request, Catalyst::Engine, > HTTP::Body and HTTP::Body::MultiPart in order to find where are the > file upload fields lost, but I > couldn't find it. > > I need to know if the form didn't have a file upload field, or if it > had it > but no file was uploaded. > > I have printed Dumper $request->_body in > Catalyst::Engine::prepare_uploads, > and when a file is uploaded, it looks like: > > $VAR1 = bless( { > 'content_length' => '1727', > 'tmpdir' => 'C:\\DOCUME~1\\Octavian\\LOCALS~1\\Temp', > 'part' => {}, > 'buffer' => '', > 'state' => 'done', > 'chunk_buffer' => '', > 'body' => undef, > 'content_type' => 'multipart/form-data; > boundary=---------------------------7da8c3070458', > 'length' => 1727, > 'boundary' => > '---------------------------7da8c3070458', > 'chunked' => '', > 'upload' => { > 'file' => { > 'headers' => { > 'Content- > Type' => > 'text/plain', > 'Content- > Disposition' > => 'form-data; name="file"; filename="E:\\zzzz_cool.txt"' > }, > 'tempname' => > 'C:\\DOCUME~1\\Octavian\\LOCALS~1\\Temp\\PrJ0ruNzzR', > 'name' => 'file', > 'size' => 44, > 'filename' => 'E:\ > \zzzz_cool.txt' > } > }, > 'param' => {}, > }, 'HTTP::Body::MultiPart' ); > > > If no file was uploaded, it prints: > > $VAR1 = bless( { > 'content_length' => '1699', > 'tmpdir' => 'C:\\DOCUME~1\\Octavian\\LOCALS~1\\Temp', > 'part' => {}, > 'buffer' => '', > 'state' => 'done', > 'chunk_buffer' => '', > 'body' => undef, > 'content_type' => 'multipart/form-data; > boundary=---------------------------7da1573870458', > 'length' => 1699, > 'boundary' => > '---------------------------7da1573870458', > 'chunked' => '', > 'upload' => {}, > 'param' => {}, > }, 'HTTP::Body::MultiPart' ); > > So the 'upload' key doesn't contain anything, not even the name of > the file > upload field. > > Can you give me a hint where I should look for finding where the > empty file > upload field is skipped if it is empty? > > Thank you. > > Octavian > > > _______________________________________________ > List: Catalyst [at] lists > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst [at] lists/ > Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: Catalyst [at] lists Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst [at] lists/ Dev site: http://dev.catalyst.perl.org/
|