My file file storage location is "E:\Records\DOCS\test.html"
我的文件存储位置是“E:\ Records \ DOCS \ test.html”
How can I get Selected file path, following is my jsp tag
我如何获得选定的文件路径,以下是我的jsp标签
<form:input path="FileData" type="file"/>
I am selecting the test.html from above path and getting the selected file my model class as follows, I am able to get selected file name but along with file name I need full path. How can I get full path in my model class ?
我从上面的路径中选择test.html并将所选文件作为我的模型类,如下所示,我能够获得选定的文件名,但随着文件名,我需要完整的路径。如何在模型类中获得完整路径?
private CommonsMultipartFile fileData;
public CommonsMultipartFile getFileData()
{
return fileData;
}
public void setFileData(CommonsMultipartFile fileData)
{
System.out.println(fileData.getOriginalFilename()); // it gives output as test.html, I need full path
return fileData;
}
1 个解决方案
#1
0
Filepaths of files selected in an <input type='file' />
tags are on the client-side. You don't need to know the filepath on the client-side, and the browser protects the client by preventing you from reading the path in any way in Javascript, and by not sending it in the request at all. All you should be concerned with is where you are going to save the file on the server-side, and you obviously would not want to save it to the same place as where it was on the client (as this would give the user the power to overwrite any file on your server they wanted). So you don't need to read any path.
在标记中选择的文件的文件路径位于客户端。您不需要知道客户端的文件路径,浏览器通过阻止您以任何方式在Javascript中读取路径,并且根本不在请求中发送它来保护客户端。您应该关注的是您要在服务器端保存文件的位置,并且您显然不希望将其保存到与客户端上的位置相同的位置(因为这会为用户提供电源)覆盖他们想要的服务器上的任何文件。所以你不需要阅读任何路径。
#1
0
Filepaths of files selected in an <input type='file' />
tags are on the client-side. You don't need to know the filepath on the client-side, and the browser protects the client by preventing you from reading the path in any way in Javascript, and by not sending it in the request at all. All you should be concerned with is where you are going to save the file on the server-side, and you obviously would not want to save it to the same place as where it was on the client (as this would give the user the power to overwrite any file on your server they wanted). So you don't need to read any path.
在标记中选择的文件的文件路径位于客户端。您不需要知道客户端的文件路径,浏览器通过阻止您以任何方式在Javascript中读取路径,并且根本不在请求中发送它来保护客户端。您应该关注的是您要在服务器端保存文件的位置,并且您显然不希望将其保存到与客户端上的位置相同的位置(因为这会为用户提供电源)覆盖他们想要的服务器上的任何文件。所以你不需要阅读任何路径。