【发布时间】:2015-01-21 17:37:42
【问题描述】:
如何获取所选文件的完整路径。
例如我选择了 logo.png
它应该得到c:\user\admin\desktop\logo.png
String im = request.getParameter("image");
InputStream inputStream = new FileInputStream(new File(im));
pstmt=con.prepareStatement("Insert into items(image) values(?)");
pstmt.setBlob(1, inputStream);
此代码插入数据库,显示以下错误
java.io.FileNotFoundException: logo.png (The system cannot find the file specified)
(尝试了一切都没有运气)
【问题讨论】:
-
如果您尝试使用
<input type="file" name="file"/>进行文件上传? -
是的,我尝试过使用,问题是当我选择浏览文件时,它只显示文件名而不是完整路径
标签: mysql database file jsp upload