


Hi , I have a form where end user will upload a image from his system from <input type="file"> and I need to fetch this image in my post servlet java file and write in excel sheet in dam path.
Any piece of code or suggestions will help.
Thanks
Views
Replies
Sign in to like this content
Total Likes
Hello @ashar02 ,
For this, you need to use Multipart/form-data. POST form data into the servlet and you can receive the image from the body part.
Once you got the image convert it into inputStream and put it into the excel cell.
JS request: https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax
The Java servlet code will be like this
RequestParameterMap requestParameterMap = request.getRequestParameterMap();
RequestParameter image = requestParameterMap.getValue("image");
InputStream inputStream = image.getInputStream();
Follow this article to put the image in excel: https://www.baeldung.com/java-add-image-excel
Hello @ashar02 ,
For this, you need to use Multipart/form-data. POST form data into the servlet and you can receive the image from the body part.
Once you got the image convert it into inputStream and put it into the excel cell.
JS request: https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax
The Java servlet code will be like this
RequestParameterMap requestParameterMap = request.getRequestParameterMap();
RequestParameter image = requestParameterMap.getValue("image");
InputStream inputStream = image.getInputStream();
Follow this article to put the image in excel: https://www.baeldung.com/java-add-image-excel