When sending multiples files with addDataToUpload:parameterName:mimeType:fileName, only the first file is recognized by the server.
The boundary is sent after each file, but it needs a "\r\n" before, as specified in the HTML Spec.
In STHTTPRequest.m:
in
+ (NSData *)multipartContentWithBoundary:(NSString *)boundary data:(NSData *)someData fileName:(NSString *)fileName parameterName:(NSString *)parameterName mimeType:(NSString *)aMimeType
EDIT: Microsoft IIS seems to be picky: if the data starts with CR LR, it throws an error 500. Nginx/PHP doesnt care.
Adding the CRLF after the data works OK
So correction is to add this line
[data appendData:[@"\r\n"dataUsingEncoding:NSUTF8StringEncoding]];
Before returning the data from multipartContentWithBoundary
When sending multiples files with addDataToUpload:parameterName:mimeType:fileName, only the first file is recognized by the server. The boundary is sent after each file, but it needs a "\r\n" before, as specified in the HTML Spec. In STHTTPRequest.m: in
+ (NSData *)multipartContentWithBoundary:(NSString *)boundary data:(NSData *)someData fileName:(NSString *)fileName parameterName:(NSString *)parameterName mimeType:(NSString *)aMimeType
[data appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
should be
[data appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
EDIT: Microsoft IIS seems to be picky: if the data starts with CR LR, it throws an error 500. Nginx/PHP doesnt care.
Adding the CRLF after the data works OK
So correction is to add this line
[data appendData:[@"\r\n"dataUsingEncoding:NSUTF8StringEncoding]];
Before returning the data from multipartContentWithBoundary