Saturday, 15 June 2013

objective c - iOS HTTP posting not working with shared server -



objective c - iOS HTTP posting not working with shared server -

hi working on ios app, there http post method signup. method working fine dedicated server. fails shared server. there no fail study in http posting delegates (nsurlconnection), "didfinish" delegate beingness called too. problem no info arrived in server side, posting plenty of details image - nil reached @ server side.

in android same posting same server working fine without issue.

what reason. please help me prepare this. here code posting.

-(void)postmethod{ nsstring *urlstring =@"http://sharedserverurl.com"; nsmutableurlrequest *request= [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:urlstring]]; [request sethttpmethod:@"post"]; nsstring *boundary = @"---------------------------14737809831466499882746641449"; nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@",boundary]; [request addvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *postbody = [nsmutabledata data]; [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@\r\n",boundary] datausingencoding:nsutf8stringencoding]]; //sending user_name [postbody appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"username\"\r\n\r\n%@", user_name.text] datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@\r\n",boundary] datausingencoding:nsutf8stringencoding]]; //sending user_id [postbody appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"user_id\"\r\n\r\n%@", user_id.text] datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@\r\n",boundary] datausingencoding:nsutf8stringencoding]]; //sending userimage [postbody appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"image\"; filename=\"userimage.png\"\r\n"] datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[@"content-type: application/octet-stream\r\n\r\n" datausingencoding:nsutf8stringencoding]]; [postbody appenddata:[nsdata datawithdata:file]]; [postbody appenddata:[[nsstring stringwithformat:@"\r\n--%@--\r\n",boundary] datausingencoding:nsutf8stringencoding]]; [request sethttpbody:postbody]; conn = [[nsurlconnection alloc] initwithrequest:request delegate:self]; if (conn) { webdata = [nsmutabledata data]; } }

ios objective-c iphone http nsurlconnection

No comments:

Post a Comment