I want full path of selected file using GWT by using FileUpload. Can you help me?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need it. Imagine that I am the client and you are the server. I give you the full file path “C:/My Documents/passwords.txt”, how would you as being the server ever programmatically access the content of the file? With
new File("C:/My Documents/passwords.txt")maybe? No, think logically about it, this ain’t going to work as we both runs at physically different machines. The information about the full path is worthless.The HTML file upload actually sends the content of the file from the client to the server, usually along with only the file name. You just need to grab the content as an
InputStreambyFileItem#getInputStream()or just to write it to disk directly byFileItem#write(). as per the FileUpload User Guide.You can get the sole filename by
FileItem#getName(), but some webbrowsers however sends the full client side disk file system path, such as Internet Explorer and Opera. This is wrong. You need to trim off the path byFilenameUtils#getName()as per the FileUpload FAQ.(by the way, all code in blue is clickable and points to the Javadocs, I strongly recommend you to learn reading/interpreting it as well, they namely provide all information you need).