I am trying to upload image from android phone to php server with additional values,the method is post
my php file look like this
if($_POST['val1']){
if($_POST['val2']){
if($_FILE['image']){
......
}
}
}else{
echo "Value not found";
}
I am doing is
URL url=new URL("http://www/......../myfile.php");
HttpURLConnection con=(HttpURLConnection) url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestMethod("POST");//Enable http POST
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "multipart/form-data;boundary="+"****");
connection.setRequestProperty("uploaded_file", imagefilePath);
DataOutputStream ostream = new DataOutputStream( con.getOutputStream());
String res=("Content-Disposition: form-data; name="val1""+val1+"****"+
"Content-Disposition: form-data; name="val2""+val2+"****"
"Content-Disposition: form-data; name="image";filename="" + imagefilePath +"""+"****");
outputStream.writeBytes(res);
my actual problem is values are not posting so first if condition get false and else section is executed that is it give value not found
please help me
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…