在多部分iphone中将图像发送到服务器 [英] send image to server in multipart iphone
问题描述
我想将图像作为多部分数据发送到服务器.
I want to send an image to the server as a multipart data.
数据必须在标题部分而不是正文部分隐藏 并且Content-Disposition:部分必须留空.
The data must be concated at the header part and not at the body part and the Content-Disposition: part must be left blank.
任何代码都非常实用. 预先感谢
Any code is really appreaciated. Thanks in advance
例如
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
我想在内容类型中附加数据.像边界一样如何做到,有boundary =%@,所以为了简化数据,使用了哪个关键字? _ =%@.?
I want to append the data in the content type. How it can be done like for boundary there is boundary=%@ so for concating the data what keyword mus be used? _=%@.?
推荐答案
在这里看看TTURLRequest是如何做到的:
Take a look at how TTURLRequest does it here:
Or how ASIHTTPRequest does it here:
Better yet, use one of those two libraries to handle the multipart post for you.
这篇关于在多部分iphone中将图像发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!