我想通过POST HTTP请求发送文件但是找不到如何处理它...
我会用字符串参数执行此操作:
String html_params = "myparam=myparam";
byte[] outputInBytes = html_params.getBytes("UTF-8");
URL url = new URL("http://www.myurl.com/senddata.asp");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "text/html");
OutputStream os = conn.getOutputStream();
os.write(outputInBytes);
os.close();
response = conn.getResponseCode();
但是我不知道如何将文件转换并发送为字节数组而不是字符串......
感谢您的帮助