xcode - Image Uploading in iOS -


currently working on image uploading in ios application , here code

afhttprequestoperationmanager *man = [[afhttprequestoperationmanager alloc]init]; man.responseserializer.acceptablecontenttypes = [nsset setwithobject:@"text/html"];  nsdata *imagedata = uiimagepngrepresentation(self.imageview.image);  afhttprequestoperation *op = [man post:addgroup parameters:@{ @"userid":@"6",                                                                 @"name":self.txtgroupname.text                                                               @"description":self.textviewgroupdescription.text,                                                                 @"image":imagedata }    constructingbodywithblock:^(id<afmultipartformdata> formdata) {                                               [formdata appendpartwithfiledata:imagedata name:@"image" filename:filename mimetype:@"image/png"];    }   success:^(afhttprequestoperation *operation, id responseobject)   {     nslog(@"success: %@ ***** %@", operation.description, operation.responsestring);     uialertview *alertview = [[uialertview alloc] initwithtitle:@"imani" message:@"new group succesfully created.." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil] ;      [alertview show];                                         }    failure:^(afhttprequestoperation *operation, nserror *error)   {      nslog(@"error: %@ ***** %@", operation.responsestring, error);   }];   [op start]; 

now getting response json image data passing null in server 1 have idea ?

thank you.

try cede upload image on server.

afhttprequestoperationmanager *manager = [[afhttprequestoperationmanager alloc] initwithbaseurl:[nsurl urlwithstring:@"your api link"]]; nsdata *imagedata = uiimagejpegrepresentation(self.imgpost.image, 0.5); nsdictionary *parameters = @{@"param": @"value",                              @"param2" : @"value2"                             }; afhttprequestoperation *op = [manager post:@"/api/store/posts/format/json" parameters:parameters constructingbodywithblock:^(id<afmultipartformdata> formdata) {     //do not put image inside parameters dictionary did, append it!     [formdata appendpartwithfiledata:imagedata name:@"file" filename:[nsstring stringwithformat:@"njoyful_%f.jpg",[nsdate timeintervalsincereferencedate]] 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]; 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -