【发布时间】:2013-10-24 09:38:46
【问题描述】:
我有一个这样的html表单
<form data-ajax="false" action='UserPhoto.php' class="settings" method='POST' enctype='multipart/form-data' >
<input type='file' style="height:25px" name='photo' />
<input type='hidden' name='task' value='upload'>
<input type='hidden' name='file_size' value='5000000'>
我想通过 webView posturl 功能上传,可以吗? 据我所知 posturl 可以通过这种方式发送字符串数据
String value1 = "persistent=1";
String value2 = "&email="+ 2nd_value;
String value3 = "&password="+ 3rd_value;
String postData = value1+value2+value3;
webView.postUrl("http://www.abc.php",EncodingUtils.getBytes(postData, "BASE64"));
但是我可以将 .png 与一些字符串值一起发布吗? 我知道另一种使用这种方式上传照片的方法
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("photo", fileName);
但这种方式不与 webview 通信,我需要使用 webview 发布照片,因为用户会话保持不变。
感谢您的帮助。
【问题讨论】:
标签: php android webview image-uploading