some questions about the upload module

Manlio Perillo manlio_perillo at libero.it
Tue Sep 9 22:28:31 MSD 2008


Valery Kholodkov ha scritto:
> Manlio Perillo wrote:
> 
>>> Yes, the data is the same multipart/form-data, but extra parameters are
>>> added as fields.
>>>
>> Can you make an example, using this sample data (from HTML 4.2 spec)?
>>
>> Content-Type: multipart/form-data; boundary=AaB03x
>>
>>     --AaB03x
>>     Content-Disposition: form-data; name="submit-name"
>>
>>     Larry
>>     --AaB03x
>>     Content-Disposition: form-data; name="files"; filename="file1.txt"
>>     Content-Type: text/plain
>>
>>     ... contents of file1.txt ...
>>     --AaB03x--
> 
> Assuming:
> 
> upload_set_form_field "${upload_field_name}_name" "$upload_file_name";
> upload_set_form_field "${upload_field_name}_type" "$upload_content_type";
> upload_set_form_field "${upload_field_name}_path" "$upload_tmp_path";
> 
> --AaB03x
> Content-Disposition: form-data; name="submit-name"
> 
> Larry
> --AaB03x
> Content-Disposition: form-data; name="files_name"
> 
> file1.txt
> --AaB03x
> Content-Disposition: form-data; name="files_type"
> 
> text/plain
> --AaB03x
> Content-Disposition: form-data; name="files_path"
> 
> <path_temporary_file>
> --AaB03x--
> 
> Where file <path_temporary_file> holds contents of file1.txt.
> 

Then I'm not sure to understand.
What's the benefit of using multipart/form-data if data is encoded in 
this way?

Isn't it better to use application/x-www-form-urlencoded?

submit-name=Larry&files_name=file1.txt&files_type=text/plain&files_path=<path_temporary_file


Note that this was the original idea I had in mind to implement.


Using multipart/form-data, I would instead return
--AaB03x
Content-Disposition: form-data; name="submit-name"

Larry
--AaB03x
Content-Disposition: form-data; name="files_name"; filename="file1.txt";
   path=<path_temporary_file>

--AaB03x--


Sorry if I'm noisy, but this is important for me, since the architecture 
of my multipart/form-data parser depends on this.



Thanks   Manlio Perillo





More information about the nginx mailing list