[Catalyst] Where is the form field lost?
Octavian Rasnita
orasnita at gmail.com
Sun Jan 24 15:03:49 GMT 2010
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
More information about the Catalyst
mailing list