在多部分iphone中将图像发送到服务器 [英] send image to server in multipart iphone

查看:63
本文介绍了在多部分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:

或者ASIHTTPRequest如何在这里完成:

Or how ASIHTTPRequest does it here:

更好的是,使用这两个库之一为您处理多篇文章.

Better yet, use one of those two libraries to handle the multipart post for you.

这篇关于在多部分iphone中将图像发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆