I am trying to write an image through HttpURLConnection.
I know how to write text, but I'm having real problems trying to write an image
I was able to record local HD using ImageIO:
But I'm trying to write Image ImageIO at the url and failed
URL url = new URL(uploadURL);
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "multipart/form-data;
boundary=" + boundary);
output = new DataOutputStream(connection.getOutputStream());
output.writeBytes("--" + boundary + "\r\n");
output.writeBytes("Content-Disposition: form-data; name=\"" + FIELD_NAME + "\";
filename=\"" + fileName + "\"\r\n");
output.writeBytes("Content-Type: " + dataMimeType + "\r\n");
output.writeBytes("Content-Transfer-Encoding: binary\r\n\r\n");
ImageIO.write(image, imageType, output);
uploadURL is the URL of the asp page on the server that will upload the image with the file name specified in the "Content-Plate: part.
now when i submit this asp page find the query and find the file name. but does not find the file to download.
The problem is that when writing ImageIO at the URL, what name of the file on which ImageIO is written,
, , , ImageIO URLConnection , asp,
, ,