AF上傳圖片問題

來源:互聯網
上載者:User

標籤:af

   前幾天用AF作網路請求,在上傳圖片的時候遇到了一些問題。。

- (void)postRequsetUploadImage:(NSString *)url Dic:(NSDictionary *)dic image:(UIImage *)image{        NSString * strUrl = [HostAddress stringByAppendingString:url];    appDelegate = [UIApplication sharedApplication].delegate;    // 佈建要求格式        [appDelegate.manager POST:strUrl parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {               NSString *fileName = [NSString stringWithFormat:@"%@.png",[dic objectForKey:@"Realname"]];        [formData appendPartWithFileData:UIImagePNGRepresentation(image) name:@"Data" fileName:fileName mimeType:@"image/png"];    } success:^(AFHTTPRequestOperation *operation, id responseObject) {                NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];        if (_dataBlock) {            _dataBlock(result,nil);        }            } failure:^(AFHTTPRequestOperation *operation, NSError *error) {        UIWindow *window = [UIApplication sharedApplication].keyWindow;        UIAlertView * ar = [[UIAlertView alloc] initWithTitle:@"提示" message:@"網路錯誤,請檢查網路" delegate:nil cancelButtonTitle:@"確定" otherButtonTitles:nil];        [window addSubview:ar];        [ar show];                hub  =(MBProgressHUD *)[window viewWithTag:5000];        if (hub) {                        [hub removeFromSuperview];        }        NSLog(@"出現錯誤: %@", error);            }];        }

代碼沒有問題 ,但是在上傳的時候,一直是未響應,網上查了很多,有很多人說是af2.0上傳的類有點問題,導致不能上傳。然後下載了很多,終於找到了一個。。

下載連結: http://download.csdn.net/detail/think_ma/8210275


AF上傳圖片問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.