delphi 调用Servlet用于图片上传,图片为二进制输入流
以下是JAVA调用的代码:
public void doUploadFile() throws Exception
{
String file= "E:/ 044160004044.jpg";
String bh = "430600100063";
String sj = "2017-09-02 11:07:23";
ByteArrayOutputStream bos = new ByteArrayOutputStream();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
int len ;
while( (len = bis.read()) > -1 ){bos.write(len);}
byte fileData [] = bos.toByteArray();
int tpsize1=fileData.length;
String urlstr="http://127.0.0.1:8080/uploadFile.tfc?method=savePicture&bh="+bh;
urlstr+= "&sj="+sj;
URL url = new URL(urlstr);
HttpURLConnection huc=(HttpURLConnection)url.openConnection();
huc.setRequestProperty("content-type", "text/html");
huc.setRequestProperty("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
huc.setDoOutput(true);
huc.setDoInput(true);
huc.setRequestMethod("POST");
huc.setConnectTimeout(500000);
OutputStream pw=huc.getOutputStream();
pw.write(fileData);
pw.flush();
pw.close();
BufferedReader br=new BufferedReader(new InputStreamReader(huc.getInputStream()));
String content="";
String line=br.readLine();
while(line!=null)
{
content=content+line;
line=br.readLine();
}
br.close();
}
请问上面的代码如何用Delphi写,我用的是Idhttp控件,就是图片这部份传不上去!