Extjs file uploading is incompatible with IE. [download and save prompt]
My favorite browser is IE, but many project customers use IE.
When Extjs is used for file upload, other browsers are fine, but IE is eager to remind you to save the file and check whether the server is running successfully, however, the progress bar of the client is loading.
The reason is:
In IE, Content-Type = application/json is downloaded and saved.
For Content-Type = text/html in IE, the returned information is processed in html format.
Therefore, we need to change the return value of response in the code so that IE can run normally:
JS Code:
Var importform = new Ext. form. formPanel ({labelAlign: 'right', fileUpload: true, items: [{xtype: 'filefield ', id: 'upfile', name: 'file', fieldLabel: 'import', labelStyle: text-align: right;, labelWidth: 50, msgTarget: 'day', allowBlank: false, anchor: '2016', buttonText: 'select file'}], buttonAlign: 'center', buttons: [{text: 'upload', handler: function () {if (importform. form. isValid () {importform. getForm (). submit ({url: 'forecast/importForecast ', waitMsg: 'submitting data', waitTitle: 'hprompt', success: function (response, options) {var message = options. result. message; if (message = OK) {Ext. msg. alert ('hprompt ', uploaded successfully);} else if (message = ver) {Ext. msg. alert ('hprompt ', check whether the version number is correct);} else if (message = type) {Ext. msg. alert ('hprompt ', the file type you uploaded is incorrect);} importWin. hide (); deliveryStore. reload () ;}, failure: function (response, options) {Ext. msg. alert ('failed', 'import file failed') ;}}}}, {text: 'reset ', handler: function () {importform. getForm (). reset () ;},{ text: 'cancel', handler: function () {importform. getForm (). reset (); importWin. hide () ;}}]});
Controller code:
/*** Upload and import data * @ param file * @ param request * @ param response * @ return * @ throws Exception */@ RequestMapping (value =/importForecast) public ResponseEntity
ImportForecast (@ RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws Exception {Map
Map = new HashMap (); map. put (roleId, request. getSession (). getAttribute (roleId ). toString (); String result =; HttpHeaders responseHeaders = new HttpHeaders (); responseHeaders. setContentType (MediaType. TEXT_HTML); try {String fileName = file. getOriginalFilename (); long size = file. getSize (); if (! (FileName = null | fileName. equals () & amp; size & gt; 0) {DmtTsUser user = (DmtTsUser) request. getSession (). getAttribute (user); result = forecastService. importForecast (file, fileName, map) ;}} catch (Exception e) {e. printStackTrace ();} String json = {success: true, message: + result +}; return new ResponseEntity
(Json, responseHeaders, HttpStatus. OK );}
The try part is the specific code for implementing file upload.