Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » multipart/form-data parsing with multi file upload support
multipart/form-data parsing with multi file upload support [message #36968] Wed, 01 August 2012 14:09
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Recently I've made a helper function which parses multipart/form-data. Field entries are added to output VectorMap and attached files are saved directly to disk. The main idea was to avoid large memory requirements even for big uploaded files due to streaming (which is critical for web servers).
The function supports multi file upload (multipart/mixed) data.

bool ParseFormData(
	Socket                   &socket, 
	dword                     timeout, 
	const String             &contentType, 
	const String             &dir,
	bool                      isFieldsListOnly, 
	VectorMap<String,String> &fields, 
	VectorMap<String,String> &files,
	const int                 maxFileSize = 100*1024*1024
	)


contentType is the string from http headers ("Content-type: ...").
dir - directory to save files to.
isFieldsListOnly - is an option to get only those fields and files which are needed (you add them to fields and files list prior to function call).

The output is fields and files maps, where fields filled with field values and files are filled with filenames.

I did not have a chance to test it thoroughly (but it successfully passed a number of test examples), so I'd be glad if anyone give me any feedback on it.

The test source with function and small example is included. Hope this helps someone.

UPDATE: test data file added.

[Updated on: Wed, 01 August 2012 22:18]

Report message to a moderator

Previous Topic: XmlRpc: Question of protection (authentification)
Next Topic: build Core to static library problem:Value.cpp | 168 | note:type was declared here
Goto Forum:
  


Current Time: Fri Mar 29 16:37:01 CET 2024

Total time taken to generate the page: 0.01348 seconds