Upload file in Android webview
- by Sunny
I have a html form like this
<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'>
and I want to upload it by using webView posturl function, is it possible?
as I know posturl can send String data by this way
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"));
but is it possible for me to post .png together with some string values?
and I know another method using this way to upload photo
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("photo", fileName);
but this way doesn't communicate with webview, I need to post the photo using webview as user session is kept with it.
Thanks for helping.