[英]upload file in JSP - how to change a default path for the uploaded file
[英]How to get accurate path of the uploaded file in jsp?
我正在嘗試使用jsp <INPUT NAME="file1" TYPE="file" >
從本地系統上載文件,並且嘗試使用文件名獲取上載文件的實際路徑。 但是我找不到正確的路徑。
我正在使用以下代碼
String filename = request.getParameter("file1");
System.out.println(filename);
String r= request.getRealPath(filename);
輸出:/home/raptor/vinoth/vinoth.k/apache-tomcat-7.0.50/wtpwebapps/LoginMonitor/file.txt代替/home/raptor/vinoth/file.txt
每次它搜索我的Web應用程序文件夾中的文件時
但是about代碼未提供實際路徑。 我正在使用Firefox瀏覽器。 誰能幫我解決這個問題?
提前致謝
您想要達到什么目的的真實路徑? 如果要在服務器上上傳/下載。請參考此鏈接http://www.javacodegeeks.com/2013/08/servlet-upload-file-and-download-file-example.html
該鏈接包含一個Web應用程序,該應用程序同時具有從本地系統上載和下載文件的操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.