开发者

Problem to post large amount of data to the web server in iphone

开发者 https://www.devze.com 2023-01-18 12:02 出处:网络
I am开发者_StackOverflow中文版working in simple application in which I need to post data to the server using webservices. I post string data to the web server, but it gives an error \"large amount of

I am 开发者_StackOverflow中文版working in simple application in which I need to post data to the server using webservices. I post string data to the web server, but it gives an error "large amount of binary data will be truncated".

NSString *queryString = [NSString stringWithFormat:@"url/message=%@",strMessage];
queryString = [queryString
        stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:queryString];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req addValue:@"text/xml; charset=utf-8"  forHTTPHeaderField:@"Content-Type"];
[req addValue:0 forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"GET"];
NSURLConnection *conn =
        [[NSURLConnection alloc] initWithRequest:req delegate:self];

Any ideas? Thanks in advance.


Did you try http://allseeing-i.com/ASIHTTPRequest/ ?

You can post any kind of datas. For example to send an image :

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];

(from http://allseeing-i.com/ASIHTTPRequest/How-to-use)

Good Luck ! :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消