我已經寫了一個代碼,以添加用戶在網絡中的項目,其工作正常..現在,我想添加另一個參數,即圖像..我無法這樣做的..我的代碼是ios - 通過POST方法發送圖像與其他參數
NSString *posturslString= [NSString stringWithFormat:@"ToDo_Item=%@&ToDo_Date=%@&AddedBy=%i",self.ToDo_Item, [dateformatter stringFromDate:self.ToDo_Date],self.AddedBy];
NSString *postData = [[NSString alloc] initWithString:posturslString];
[request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = [[NSURLResponse alloc] init];
self.receivedData =[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
NSError * error;
NSDictionary *user = [NSJSONSerialization JSONObjectWithData:self.receivedData
options:0
error:&error];
NSNumber *successNumber = [user objectForKey:@"success"];
success = [successNumber integerValue];
我怎麼能與我的其他參數一起發送圖像即NSData的
NSData *png=UIImagePNGRepresentation(self.itemImage.image);
。請幫助。
請參考這裏nk:[發佈數據與圖像](http://stackoverflow.com/questions/32662658/sending-nsdata-and-nsstring-in-the-same-post/32719056#32719056) –