Upload Files to Database

How to upload files to database using JSP?

Questions by Nusraths9

Showing Answers 1 - 3 of 3 Answers

chandrashekar

  • May 15th, 2017
 

We can upload file into data base using form encrypt type multipart concept

Code
  1. In jsp:

  2.  <form method="post" action="uploadServlet" enctype="multipart/form-data">

  3. <input type="file" name="photo" size="50"/></input>

  4. </form>

  5. In Controller part:

  6. @MultipartConfig(maxFileSize = 16177215)    // upload files size up to 16MB

  7.   Part filePart = request.getPart("photo");//obtains the upload file part in this multipart request

  8.    InputStream inputStream inputStream = filePart.getInputStream();

  9. if(filePart !=null){

  10. Do data base actions

  11. Note:to insert files into data base we use BLOGs

  12. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions