我想用jsp将文件上传到mysql数据库中。当我使用input type =“file”时,jsp没有返回完整路径。我需要完整的路径上传一个文件在MySQL数据库。我想用jsp将文件上传到mysql数据库
<form id="translationFormID" method="post" action="saveTranslation">
<input type="file" name="attachCV" id="attachCVID" value="Attach CV">
<input type="submit" name="submit" />
</form>
这是我的jsp页面。我使用post方法调用servlet'saveTranslation'。
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String attachCV=null;
try{
String attachCV=request.getParameter("attachCV");
System.out.println("path= "+attachCV);
}
catch(Exception){
e.printStackTrace();
}
}
这是我的servlet代码。这里获取并打印attachCV参数。当我打印attachCV,它显示类似'c:\ fakepath \ sample.docx'
继续。你有我们的许可。:-)既然你没有发布任何能够显示你所尝试的代码的代码,你的问题很可能会被关闭。这里没有足够的信息来回答你的问题。仅仅使用'input type ='file''不会告诉你的服务器在哪里存储它,并且保存到客户端文件夹的“完整路径”(这是设置'输入类型'可用的设置)在服务器上是没有意义的。 –
请给出一些建议。 –
如果您不再重新发布相同的问题,情况会很好。谢谢。 – Kev