Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should a Multipart HTTP request with multiple files look like? [duplicate]

I'm working on an iPhone app that makes a multipart HTTP request with multiple image files.

It looks like what's happening, on the server side, is that one of the images is getting parsed properly, but the other two files are not.

Can anybody post a sample HTTP multipart request that contains multiple image files?

like image 394
bpapa Avatar asked May 27 '09 02:05

bpapa


People also ask

What is HTTP multipart request?

An HTTP multipart request is an HTTP request that HTTP clients construct to send files and data over to an HTTP Server. It is commonly used by browsers and HTTP clients to upload files to the server.

What is the easiest way to upload single or multiple files with FormData?

Uploading Multiple Files const uploadFile = (files) => { console. log("Uploading file..."); const API_ENDPOINT = "https://file.io"; const request = new XMLHttpRequest(); const formData = new FormData(); request. open("POST", API_ENDPOINT, true); request. onreadystatechange = () => { if (request.

What is a multi part file?

Multipart requests combine one or more sets of data into a single body, separated by boundaries. You typically use these requests for file uploads and for transferring data of several types in a single request (for example, a file along with a JSON object).


1 Answers

Well, note that the request contains binary data, so I'm not posting the request as such - instead, I've converted every non-printable-ascii character into a dot (".").

POST /cgi-bin/qtest HTTP/1.1 Host: aram User-Agent: Mozilla/5.0 Gecko/2009042316 Firefox/3.0.10 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://aram/~martind/banner.htm Content-Type: multipart/form-data; boundary=2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f Content-Length: 514  --2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f Content-Disposition: form-data; name="datafile1"; filename="r.gif" Content-Type: image/gif  GIF87a.............,...........D..; --2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f Content-Disposition: form-data; name="datafile2"; filename="g.gif" Content-Type: image/gif  GIF87a.............,...........D..; --2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f Content-Disposition: form-data; name="datafile3"; filename="b.gif" Content-Type: image/gif  GIF87a.............,...........D..; --2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f-- 

Note that every line (including the last one) is terminated by a \r\n sequence.

like image 125
Daniel Martin Avatar answered Oct 11 '22 15:10

Daniel Martin