I'm working with some code that uploads an image from a form and stores it on our server. In Internet Explorer the user can enter a path manually, and I wonder how I can check that the file exists, i.e., that the user entered a valid path.
There's a FileItem object that's being used to check size (e.g., fileItem.getSize() < MAX_SIZE), and I wonder if a good approach would be to use size to check that the file exists. For example:
if (fileItem.getSize() == 0) {
// Somethings wrong -- invalid path.
} else {
// File exists -- valid path.
}
Any suggestions are appreciated. Thanks! I think you don't even get a FileItem when there is nothing uploaded.
以上就是Checking for a Valid Path when Uploading a File Using commons-fileupload的详细内容,更多请关注web前端其它相关文章!