I've found some tutorial teaching me how to upload a file to my server through PHP and html form.
Even throught I always fail in all of these tutorial :(... I still assume these tutorial is correct.
Most of these tutorial tall me that we can make metatdata form in PHP in our server, and use HttpURLConnection class in android.
But I can't figure our how these tutorial automatically push the "submit" as what we usually do in browser @@"
Most these tutorial like this:
URL url =new URL(actionUrl);
HttpURLConnection con=(HttpURLConnection)url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestMethod("POST");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Charset", "UTF-8");
con.setRequestProperty("Content-Type",
"multipart/form-data;boundary="+boundary);
//omit some code that start to output the file stream to url connection stream
ds.writeBytes(end);
ds.writeBytes(twoHyphens + boundary + twoHyphens + end);
//omit some code theat start read url connection response stream
(I am sorry that i omit some lines of minor code here, but the tutorial result tell us that after we use these connection setup to PHP form, we can get the response from another PHP action page that stroe file in server and return some info about the file)
So, I guess these tutorial essentially push the "submit" button in someway, because we get response from action PHP page rather than the PHP form(with submit button) page.
But I can't figure out how they do it at all....
Anyone can help me??? Thx!!
(if you have better solution to upload file to server or manipulate with PHP webpage, please also give me some suggestion!! thx!!)