Image writing over URLConnection

Image writing over URLConnection

Hello, I am trying to write an image over an HttpURLConnection.

I know how to write text but I am having real problems trying to write an image

I have succeeded in writing to the local HD using ImageIO:

But I am trying to write Image by ImageIO on 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);

the uploadURL is the url to an asp page on the server which will upload the image with the file name given in "content-Disposition: part.

now when I send this then asp page find the request and find the name of file. but does not find the file to be uploaded.

The problem is that when writing by ImageIO on URL what will the name of the file on which the ImageIO is writing,

So please help me how ImageIO will write an image on URLConnection and how can I know the name of the file which I have to use in the asp page to upload the file

Thanks for taking the time to read this post Dilip Agarwal

Thanks for your time

View Answers









Related Tutorials/Questions & Answers:
Image writing over URLConnection
Image writing over URLConnection  Hello, I am trying to write an image over an HttpURLConnection. I know how to write text but I am having real problems trying to write an image I have succeeded in writing to the local HD using
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
Advertisements
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf using itext?  I am writing a pdf using itext where i add a image in the beginning of the document. When i use image = Image.getInstance("C
Print the URL of a URLConnection
Print the URL of a URLConnection       In this section we are going to describe, how to retieve... that we use the getURL() which returns the value of this URLConnection's URL field
Version of com.jdroidframework>jdroid-java-http-urlconnection dependency
List of Version of com.jdroidframework>jdroid-java-http-urlconnection dependency
Open a URLConnection to specific website address
Open a URLConnection to specific website address       Here we are going to establish... of URLConnection. After that we put the try and catch block and assign a URL
Ghost Writing
Ghost Writing Ghost Writing is the kind of writing when someone... of writing it. So ghostwriter is a person who works behind the scene on a writing project in return of certain amount. The write-ups of the writer
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
writing characters
writing characters  how to write a group of characters to a string ... i mean for writing single character using charAt in java
Maven Dependency jdroid-java-http-urlconnection >> 0.8.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.8.0 in your project
Maven Dependency jdroid-java-http-urlconnection >> 0.9.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.9.0 in your project
Maven Dependency jdroid-java-http-urlconnection >> 0.9.1
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.9.1 in your project
SEO Writing
is the demand of SEM and SEO article writing services. A good command over...SEM and SEO Article Writing SEM and SEO article helps your business to grow... the intended traffic through SEM and SEO article writing in addition to other tools
method over riding
method over riding  write a java program to compute volume of sphere and volume of cylinder using method over riding
Blog Writing
Blog Writing A blog, the short form of web log is an online user... on that. But the professionals are a better choice for writing the blog for commercial or promotional purpose. We provides the services of writing blogs for the commercial
mouse over effects in css
mouse over effects in css  I have written a mouse over effect in CSS. But it is not working in HTML. Can any one suggest me? Thanks
Call UIViewController over RootViewController
Call UIViewController over RootViewController   Hi, i have created the window based application.. but not sure how to call the UIView over RootViewController. Thanks
Writing Actions
Writing Actions The Action is responsible for controlling of data flow within an application. You can make any java class as action. But struts have some built in interface and class for making action easily. To make an Action class
Data over Voice Communication
Data over Voice Communication  I just Want to know that Data Over Voice communication is possible in India or Not, If not then Why. and If Yes then Why Please anyone give the answer
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
application over https
application over https   Hi. This questions might be very simple but I would like to create a simple servlet program and want to access using https... while accessing https over http
hibernate over Jdbc
hibernate over Jdbc  Why use hibernate over Jdbc?   Hibernate provides lots of advantages over JDBC. Some of them are as below: 1) Hibernate is data base independent 2) Hibernate provides its own query language called
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Articles Writing,Articles Writing Services,Articles Writing India,Articles Writing & Content Development
Articles Writing and Content Development In web medium, content... be readable by all. As far as writing an article is concerned, then it becomes... and understandable by all in general. Article writing is the driving force of your
RMI over Internet - RMI
RMI over Internet  Hello I've made a project which utilizes rmi for communication. Problem: I am unable to communicate using rmi over internet 1)the clients cannot connect to me 2)I am using client side callbacks 
writing plugin - WebSevices
writing plugin  can anyone help me in writing plugin for internet explorer browser using c++ in .net environment
writing HTML entirely by hand
writing HTML entirely by hand  How comfortable are you with writing HTML entirely by hand
Is AI taking over the world?
Is AI taking over the world?  Hi, I am beginner in Data Science... taking over the world? Try to provide me good examples or tutorials links so that I can learn the topic "Is AI taking over the world?". Also tell me
why should we over ride hashCode(), when equals was over ride()?
why should we over ride hashCode(), when equals was over ride()?  why should we over ride hashCode(), when equals was over ride
Web Writing
Web Writing       The art of writing for the web is far removed from writing for the print world.... Following is the prime aspect you need to keep in mind while writing for the web
Transmitting messages over net
Transmitting messages over net  A method whereby messages to be transmitted between computers are all sent to a central computer, which gathers them and routes them to the appropriate destinations is known as - 1. Message
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
What is the advantage of hibernate over JDBC?
What is the advantage of hibernate over JDBC?  HI, What is the advantage of hibernate over JDBC? thanks
What is the advantage of hibernate over JDBC?
What is the advantage of hibernate over JDBC?  HI, What is the advantage of hibernate over JDBC? thanks
Content Writing Job
be fluent in writing Good command over language and grammar... Content Writing Job       In the field of Content writing it is very important
ModuleNotFoundError: No module named 'over-stats'
ModuleNotFoundError: No module named 'over-stats'  Hi, My Python... 'over-stats' How to remove the ModuleNotFoundError: No module named 'over... have to install padas library. You can install over-stats python
Freelance Writing as a Career
Freelance Writing as a Career Pen has a great power of its own and its... and journalists. Freelance Writing – What Is Required? Choosing freelance writing as a career seems to be an extremely easy way of making bucks
Swap images oon mouse over and mouse out
Swap images oon mouse over and mouse out  I have multiple images...i want to swap each image on mouse out and mouse over..   <html>...) { arr = new Array(); arr[1] = new Image(); arr[1].src = "rose1.jpg"; arr[2] = new

Ads