Uploading an image from iOS to PHP Uploading an image from iOS to PHP ios ios

Uploading an image from iOS to PHP


Now i've solved it by myself =)

I forgot the backslashes in the body.

Here is the right body:

NSMutableData *body = [NSMutableData data];[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"uploadedfile\"; filename=\"test.png\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];[body appendData:[NSData dataWithData:imageData]];[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];[request setHTTPBody:body];


matomo