how to get full path for upload a file in jsp?

时间秒杀一切 提交于 2019-11-29 07:53:13
Scary Wombat

JSP is code that produces the client facing HTML code (commonly called the View) and the Servlet is server code. In reality they will be on different machines, so what is the use of the full path. The file contents should be POSTED to the servlet when submitting your form.

your jsp should something like:

<form action="UploadServlet" method="post"
                        enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>

Of course you have other input fields as well.

See this link

How to upload files to server using JSP/Servlet?

The Local filepath is useless on the server-side. It would only be of use to hackers. That's why browsers don't send it. Its a security measure. You should be glad its there. I'm surprised none of the existing answers pointed this out.

On the server-side you decide where to save the file. You wouldn't want the user deciding that, obviously. Giving them the ability to decide where to save the file on your server would give them the ability to overwrite your system files.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!