我正在使用spring MVC进行文件上传,它在firefox和chrome中工作正常,但在IE中它显示上传失败..下面是我的jsp页面,我包含fileuploader函数。
<div id="file-uploader-demo1" style="float: left;padding-top: 10px"></div>
</div>
<script>
function createUploader(){
var uploader = new qq.FileUploader ({
element: document.getElementById('file-uploader-demo1'),
action: '/Flas_ _/commu-____/insertFile;jsessionid=${sessionId}',
headers: {'Content-type':'multipart/form-data'},
multipleFileUpload: false,
debug: true
});
}
window.onload = createUploader;
</script>
这是我的 jsp 页面,其中 iam 包括 FileUploader.js 文件,动作标签调用我各自的控制器,如下所示..
@RequestMapping(value = "/insertFile", method = RequestMethod.POST)
public String fileUpload(@RequestParam("qqfile") String filename1,ModelMap map,
HttpServletRequest request,HttpServletResponse response) throws IOException {
PrintWriter writer = null;
InputStream is = null;
FileOutputStream fos = null;
try {
writer = response.getWriter();
} catch (IOException ex) {
//log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
}
String filename = request.getHeader("X-File-Name");
this.setFILEUPLOAD(filename);
try {
is = request.getInputStream();
fos = new FileOutputStream(new File("F:/images/" + filename));
IOUtils.copy(is, fos);
response.setStatus(response.SC_OK);
writer.print("{success: true}");
} catch (FileNotFoundException ex) {
response.setStatus(response.SC_INTERNAL_SERVER_ERROR);
writer.print("{success: false}");
// log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
}catch (IOException ex) {
response.setStatus(response.SC_INTERNAL_SERVER_ERROR);
writer.print("{success: false}");
// log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
} finally {
try {
fos.close();
is.close();
} catch (IOException ignored) {
}
}
writer.flush();
writer.close();
return "do-nothing";
}
尽管在 CHROME 和 FIREFOX 中它的工作正常,我将文件存储在语言环境驱动器中。但它在 IE 9 中不起作用。我应该怎么做我没有得到。
dis有什么解决办法吗?请帮助谢谢。