php - Unable to upload image using AFNetworking AFURLSessionManager Multi-Part Request -
i trying upload image php service using afurlsessionmanager upload task multi-part request, progress.
however, server not receiving image. here code:
-(void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { [self dismissviewcontrolleranimated:yes completion:nil]; uiimage *pic = [info objectforkey:uiimagepickercontrollereditedimage]; self.profilepic.image = pic; nsdata *picdata =uiimagejpegrepresentation(pic, 0.5); nsmutabledictionary *parameters = [[nsmutabledictionary alloc]init]; [parameters setvalue:self.currentuser.userid forkey:@"id"]; [parameters setvalue:self.currentuser.token forkey:@"token"]; nsmutableurlrequest *request = [[afhttprequestserializer serializer] multipartformrequestwithmethod:@"post" urlstring:dpupdateurl parameters:parameters constructingbodywithblock:^(id<afmultipartformdata> formdata) { [formdata appendpartwithfiledata:picdata name:@"image" filename:@"name.jpg" mimetype:@"image/jpeg"]; [formdata appendpartwithformdata:[[nsnumber numberwithint:picdata.length].stringvalue datausingencoding:nsutf8stringencoding] name:@"image"]; } error:nil]; afurlsessionmanager *manager = [[afurlsessionmanager alloc] initwithsessionconfiguration:[nsurlsessionconfiguration defaultsessionconfiguration]]; nsprogress *progress = nil; nsurlsessionuploadtask *uploadtask = [manager uploadtaskwithstreamedrequest:request progress:&progress completionhandler:^(nsurlresponse *response, id responseobject, nserror *error) { if (error) { nslog(@"error: %@", error); } else { nslog(@"%@ %@", response, responseobject); } }]; [uploadtask resume]; }
in php file using following code:
move_uploaded_file($_files['image']['tmp_name'],"../dp_images/$user_id.jpg" );
here response getting.
<nshttpurlresponse: 0x8d6f590> { url: http://www.appdomain.com/dp_update.php } { status code: 200, headers { connection = "keep-alive"; "content-length" = 0; "content-type" = "text/html"; date = "mon, 18 aug 2014 07:49:56 gmt"; "keep-alive" = "timeout=5, max=100"; server = apache; } } (null)
is there doing wrong?? appreciate :)
Comments
Post a Comment