ios - Upload an image after 64-bit encoding -


i want upload image on server. encode 64-bit post. using code:

nsurl *url=[[nsurl alloc] initwithstring:@"http://boomagift.ramansingla.com/userpicture.php?email=sonal@gmail.com"];  nsmutableurlrequest *req=[[nsmutableurlrequest alloc] initwithurl:url]; [req sethttpmethod:@"post"]; // [req setvalue:@"multipart/form-data; boundary=*****" forhttpheaderfield:@"content-type"];  nsmutabledata *postbody=[nsmutabledata data]; nsstring *boundary=@"*****";   [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@\r\n",boundary] datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"uploadedfile\"; filename=\"test.png\"\r\n"] datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[@"content-type: application/octet-stream\r\n\r\n" datausingencoding:nsutf8stringencoding]]; nsstring *this=[pickedimagedata base64encodedstring];  [postbody appenddata: [this datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@--\r\n",boundary] datausingencoding:nsutf8stringencoding]]; [req sethttpbody:postbody];   nshttpurlresponse *response=nil;         nserror *error=[[nserror alloc] init];  nsdata *responsedata;     responsedata=[nsurlconnection sendsynchronousrequest:req returningresponse:&response error:&error];     nslog(@"%@",responsedata);     if(responsedata&&[responsedata length])     {          nsdictionary *dictionary=[nsjsonserialization jsonobjectwithdata:responsedata options:0 error:&error];         nslog(@"%@",dictionary);     }     else     {         nslog(@"hello");     } 

-(nsarray *)getresizeduimage:(uiimage *)getimage othervalueone:(float)newwidth othervaluesecond:(float)newheight {     cgrect rect = cgrectmake(0.0, 0.0, newwidth, newheight);     uigraphicsbeginimagecontextwithoptions(rect.size, no, 1);     [getimage drawinrect:rect];     uiimage *img = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();     nsarray *loadimagedatearray = [[nsarray alloc]init];     uiimage *imageconvert = img;     nsdata *data = uiimagejpegrepresentation(imageconvert, 0.8);     nsstring *base64string = [data base64encodedstringwithoptions:0];     loadimagedatearray = [nsarray arraywithobject:base64string];     return loadimagedatearray; } 

this code part return base 64 try update answer use function, function return base 64


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -