我想太多圖片上傳到服務器,但是,這樣做上傳圖片不能正常工作
我用下面的代碼,但不知道什麼是錯在那裏
遇到錯誤+(void) HTTPPostImage:(NSString *) stringURL andParameter:(NSData *) imageData andSelector:(SEL) selector andTarget:(id) target{
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:stringURL]];
// NSData *imageData = UIImageJPEGRepresentation(self.avatarView.image, 0.5);
NSDictionary *parameters =NULL;
NSString *myUUID = [[NSUUID UUID] UUIDString]; // create a UUID
NSLog(@"myUUID%@",myUUID);
AFHTTPRequestOperation *op = [manager POST:@"" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"public.image" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
//[formData appendPartWithFileData:imageData name:@"file" fileName:myUUID mimeType:@"image/jpeg"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@ ***** %@", operation.responseString, responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@ ***** %@", operation.responseString, error);
}];
[op start];
}
我不知道什麼是錯在這個參數
[formData appendPartWithFileData:imageData name:@"public.image" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
對於服務器參數
我不知道我是否做了錯誤或服務器已經做了
我買了名稱混淆:@「userfile的」文件名:@「photo.jpg」 mime類型:@「圖像/ JPEG」]應該是什麼,這些參數在用戶的情況下點擊image –
@「userfile」是php服務端的圖像參數類型@nischalhada – Nikunj
我用 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info來捕獲圖像。你可以給我一些想法什麼將參數 –