Reputation: 179
I intend to upload image to server using asiformdatarequest.my code like:
UIImage *image = [UIImage imageNamed:@"testicon.jpg"];
NSData *imgData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((image), 0.5)];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:ADDRESS,myType,action]];
ASIFormDataRequest *currentRequest = [ASIFormDataRequest requestWithURL:url];
[currentRequest setPostFormat:ASIMultipartFormDataPostFormat];
[currentRequest addRequestHeader:@"Content-Type" value:@"multipart/form-data"];
[currentRequest setRequestMethod:@"POST"];
[currentRequest setPostValue:@"1" forKey:@"user_id"];
NSLog(@"responseString = %@",responseString);
but the server don't return correct result.what' s the problem it might be?
Upvotes: 3
Views: 1156
Reputation: 11839
You are not setting data-
[currentRequest setData:imgData forKey:@"file"];
Upvotes: 1