FileUpload代码
来自/ UploadSubmission Servlet at doPost
try{
if (isMultipart)
{
ServletFileUpload upload = new ServletFileUpload();
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
UnzipUtility utility = new UnzipUtility();
try{
// Parse the request
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
System.out.println(item.getName());
//continues
}
catch(Exception ex)
{
ex.printStackTrace();
}
当我运行它时,它适用于Internet Explorer,firefox 但是,当我在谷歌浏览器上运行它时:它给了我这个错误
java.io.FileNotFoundException: ERROR_DEMO.zip (The system cannot find the file specified)
这是HTML部分
<form name="UploadSubmission" id="UploadSubmission"
action="/JavaProject/UploadSubmission" enctype="multipart/form-data" method="post">
<input type="file" name="fileName"
accept="application/zip">
</form>