Extjs file uploading is incompatible with IE. [download and save prompt]

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.