Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="javax.servlet.annotation.MultipartConfig"%>
- <%@page import="java.sql.*"%>
- <%@page import="java.io.InputStream"%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%
- request.setCharacterEncoding("UTF-8");
- Part p = request.getPart("image");
- InputStream inputStream = null;
- if (p != null) {
- inputStream = p.getInputStream();
- }
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://localhost:3306/test42";
- Class.forName(driver);
- Connection con = DriverManager.getConnection(url, "root", "1234");
- String sqlString = "INSERT INTO test42.images items(idimages) values(" + inputStream + ");";
- String msg = p.toString();
- %>
- <form method="post" action="mainPage.jsp" enctype="multipart/form-data">
- choose file :
- <input type="file" name="image" />
- <input type="submit" value="submit">
- </form>
- java.lang.IllegalStateException: Request.getPart is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement