上传现有图像时出现500错误

时间:2015-01-31 04:43:03

标签: java image apache jsp servlets

我无法使用servlet将图像上传到我的数据库,我收到以下错误。

HTTP Status 500 - troubleshoot.png (No such file or directory)

type Exception report
message troubleshoot.png (No such file or directory)   
description The server encountered an internal error that prevented it from fulfilling this request.
exception java.io.FileNotFoundException: troubleshoot.png (No such file or directory)
java.io.FileInputStream.open(Native Method)
java.io.FileInputStream.<init>(FileInputStream.java:146)
ActionObject.Input.doGet(Input.java:54)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.

这是我的代码:

input class="filestyle" type="file" name="photo" size="10"  
required="required" accept="image/*">

我的web.xml文件包含:

<context-param>
      <param-name>tempfile.dir</param-name>
      <param-value>tmpfiles</param-value>
</context-param>

将图像名称设置为文件的Java代码:

 st.setPic(new FileInputStream(new File(request.getParameter("photo"))));

0 个答案:

没有答案
相关问题