I want to upload an image to DB. i use java servlet
for this purpose. but i got an exception
HTTP Status 500 - Unable to process parts as no multi-part configuration has been provided
my jsp page:
<form action="uploadservlet" method="post"
enctype="multipart/form-data">
<input type="file" name="photo" size="50"/>
<br />
<input type="submit" value="Upload File" />
</form>
and my servlet post method is
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException {
InputStream inputStream = null; // input stream of the upload file
// obtains the upload file part in this multipart request
Part filePart = request.getPart("photo");
if (filePart != null) {
// prints out some information for debugging
System.out.println(filePart.getName());
System.out.println(filePart.getSize());
System.out.println(filePart.getContentType());
// obtains input stream of the upload file
inputStream = filePart.getInputStream();
}
}