用AFNetworking上传图片报Request failed: 未找到 (404)错

今天做上传图片功能,
直接贴代码

 +(void)uploadImgWithImgData:(NSData *)imgData aiv:(UIActivityIndicatorView *)aiv loginName:(NSString *)loginName type:(NSString *)type idStr:(NSString *)idStr successB:(void(^)(id responseObj))successB failB:(void(^)(NSError *error))failB{
    if ( imgData.length > 0  && loginName.length> 0  && type.length > 0  && idStr.length > 0) {
        NSLog(@"imgdata:%@",imgData);
        NSDate *date = [NSDate date];
        NSString *dateStr = (NSString *)date;
        NSString *fileName = [NSString stringWithFormat:@"%@.jpg",dateStr];

        NSString *currentURL = @"/up/save";
//                NSString *urlStr = [NSString stringWithFormat:@"%@%@",BASEURL,currentURL];
        NSString *urlStr  = [NSString stringWithFormat:@"%@%@?loginName=%@&type=%@&id=%@",BASEURL,currentURL,loginName,type,idStr];
//                NSDictionary *param = [NSDictionary dictionaryWithObjects:@[loginName,type,idStr] forKeys:@[@"loginName",@"type",@"id"]];
        NSLog(@"url:%@",urlStr);


        AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
        manager.requestSerializer = [AFHTTPRequestSerializer serializer];
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];

        [manager POST:urlStr parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
            [formData appendPartWithFileData:imgData name:@"pic" fileName:fileName mimeType:@"image/jpeg"];
        } success:^(AFHTTPRequestOperation *operation, id responseObject) {

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

           NSLog(@"eerr:%@",error);
            [Util showAlertView:[error localizedDescription]];
        }];
    }
}

提交图片的同时还要提交三个参数
报错:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: 未找到 (404)" UserInfo=0x7f84ffa23a50 {com.alamofire.serialization.response.error.response= { URL: http://172.23.128.61:1100/up/save?loginName=136xxxx1375&type=nursery&id=55db127caa9bd30281e32f40 } { status code: 404, headers {

"Cache-Control" = "must-revalidate,no-cache,no-store";
"Content-Length" = 1372;
"Content-Type" = "text/html;charset=ISO-8859-1";
Server = "Jetty(8.y.z-SNAPSHOT)";
Vary = "Accept-Encoding";
} }, NSErrorFailingURLKey=http://172.23.128.61:1100/up/save?loginName=13657xxxx75&type=nursery&id=55db127caa9bd30281e32f40, com.alamofire.serialization.response.error.data=, NSLocalizedDescription=Request failed: 未找到 (404)}
请问是怎么回事?

查看全部
peterchen149
peterchen149
2015/08/24 12:52
  • ios
  • 点赞
  • 收藏
  • 回答
    私信

5个回复