1

I am trying to upload an image to an server.

I do this using an script (in objective-c) and request an php page on the server. I found on the internet some example code to use (which was very useful).

Link: How to send post data and image file to server Xcode

Somewhere in the sample code they are setting "boundaries" before requesting the page. It looks like this:

NSString *boundary = [NSString stringWithString:@"-------------------------- 14737809831466499882746641449" ];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];

Question: What are boundaries and what does it do?

  • http://en.wikipedia.org/wiki/MIME – Marc B Dec 19 '14 at 15:23
  • Googling html boundary gave me the result http://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data – Varedis Dec 19 '14 at 15:26
  • So for the server to see the difference between two variables in a GET request we use the "&". And when you use a POST request you have to set boundaries so the server can see the difference? Is this correct? When I use only one variable do I still have to set the boundaries? –  Dec 19 '14 at 15:31
  • It isn't the difference between POST and GET, it's the difference between multipart form data and other content types (MIME types). – Wain Dec 19 '14 at 16:33

0 Answers0