使用UIWebView上传照片 [英] Upload a photo using UIWebView
本文介绍了使用UIWebView上传照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在远程服务器中有一个网页(比如filebrowse.html),有一个浏览文件按钮,我想通过 UIWebView
访问该页面并上传我的画廊的照片。 (画廊在iPhone上。)
Suppose I have a web page (say filebrowse.html) in a remote server, having a browse file button, I want to access this page via a UIWebView
and upload photo from my gallery. (The gallery is on the iPhone.)
这可能吗?
推荐答案
在iOS上,无法浏览文件系统,因此您无法使用UIWebView中的表单附加照片进行上传。答案相当令人费解,但这里有:
On iOS, there is no way to "browse the filesystem" so you can't use a form in UIWebView to attach photos for upload. The answer is rather convoluted but here goes:
你将不得不 -
- UIImagePickerController从相册中获取图片。
- 确定提交表单的POST标题
- 将图像编码为NSData
- 使用NSURLConnection写一个POST请求,NSData对象插入正确的标题
- UIImagePickerController to get a picture from the photos album.
- Determine the POST headers for the submit form
- Encode the image as NSData
- Write a POST request with NSURLConnection with the NSData object getting inserted in the proper header
I无法真正为您提供所有这些的代码,因为它需要分解为所有这些步骤。
I can't really give you the code for all of this because it needs to be broken down into all of those steps.
这篇关于使用UIWebView上传照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文