I'm trying to use ASIFormDataRequest to send a photo image from my iPhone app to my server.
When I do so, the server sends back an error message saying, "must be an image file," implying that there is something wrong with the formatting of my image. (Of course, that might not be the problem...but it's a good place to start.) I know there's no "problem," per se, on the server, because a previous approach I used (non-ASIHTTPRequest-based) worked fine. Here's my iPhone code:
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:
[NSURL URLWithString:photoUploadURLString]];
request.username = self.username;
request.password = self.password;
[request setPostValue:self.place.placeId forKey:@"place_id"];
NSData* jpegImageData = UIImageJPEGRepresentation(self.photo,
PHOTO_JPEG_QUALITY);
NSString* filename = [NSString stringWithFormat:@"snapshot_%@_
%d.jpg", self.place.placeId, rand()];
[request setData:jpegImageData withFileName:filename
andContentType:@"image/jpeg" forKey:@"snapshot[image]"];
request.uploadProgressDelegate = self.progressView;
[request startSynchronous];
Anyone see anything wrong with this? (I'm fairly new to this stuff, so there could be something obvious I'm missing.)
Thanks very much.