下面是我用来将文件上传到服务器的代码。但是代码抛出异常目录或找不到文件..
ResourceBundle rs_mail = ResourceBundle.getBundle("mail");
String upload_path = rs_mail.getString("upload_path");
File file = null;
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request to get file items.
List fileItems = upload.parseRequest(request);
// Process the uploaded file items
Iterator i = fileItems.iterator();
while (i.hasNext()) {
FileItem fi = (FileItem) i.next();
File uploadDir = new File(upload_path);
if (!uploadDir.exists()) {
uploadDir.mkdir();
}
file = new File(upload_path + file.separator + fi.getName());
fi.write(file);
}
谁能指出异常的原因..
属性文件的内容
上传路径=../../../上传