AFNetworking上传图片,服务器接收不到

原来一直都没问题的,不知道什么原因从昨天开始就上传不了,没报错,但是服务器就是接收不到。。

+(void)uploadImgWithImgData:(NSData *)imgData loginName:(NSString *)loginName type:(NSString *)type idStr:(NSString *)idStr{

NSDate *date = [NSDate date];

NSString *dateStr = (NSString *)date;

NSString *fileName = [NSString stringWithFormat:@"%@.jpg",dateStr];

NSString *currentURL = @"/up/save";

NSString *urlStr= [NSString stringWithFormat:@"%@%@?loginName=%@&type=%@&id=%@",UPLOADIMGBASEURL,currentURL,loginName,type,idStr] ;

NSLog(@"urlstr:%@",urlStr);

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager POST:urlStr parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

[formData appendPartWithFileData:imgData name:@"pic" fileName:fileName mimeType:@"image/jpeg"];

} success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSLog(@"success:%@",responseObject);

[Util showMsgSendFromServer:[responseObject objectForKey:@"msgs"]];

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"eerr:%@",error);

}];

}

更新:在网上搜到这个
图片描述

问一下怎么抓包?

回答:

服务器是从 pic 字段读取文件的吗?

以上是 AFNetworking上传图片,服务器接收不到 的全部内容, 来源链接: utcz.com/p/186807.html

回到顶部