AFHTTPRequestOperationManager *?manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer= [AFHTTPResponseSerializer serializer];
[manager POST:url parameters:params constructingBodyWithBlock:^(id formData) {
NSData *data =UIImageJPEGRepresentation(image,0.5);//把要上傳的圖片轉成NSData
//把要上傳的文件轉成NSData
//NSString*path=[[NSBundlemainBundle]pathForResource:@"123"ofType:@"txt"];
//NSData*fileData = [NSDatadataWithContentsOfFile:path];
[formData appendPartWithFileData:dataname:@"uploadFile" fileName:@"圖片1" mimeType:@"image/png"];//給定數據流的數據名,文件名,文件類型(以圖片為例)
/*常用數據流類型:
@"image/png" 圖片
?@“video/quicktime” 視頻流
*/
}success:^(AFHTTPRequestOperation*operation,id responseObject) {
//NSLog(@"%@",responseObject);//返回結果
}failure:^(AFHTTPRequestOperation*operation,NSError*error) {
//NSLog(@"%@",error.localizedDescription);//請求失敗結果
}];