Extjs fileupload - cross-origin frame

后端 未结 3 970
你的背包
你的背包 2021-01-02 17:22

I have a fileupload field in my from in Extjs application. Where I am trying to load files to the server by following code:

var form = Ext.getCmp(\'ProcImpNe         


        
3条回答
  •  清歌不尽
    2021-01-02 18:03

    This is an improvement of cheftao answer.

    If you need to work with different domains (e.g. localhost with a different port), follow these steps:

    on the client side, before submitting the form, renew the document domain and then submit it with the form data:

      document.domain = document.domain;
      myForm.submit({
        params: {
          domain: document.domain
        },
        ...
      });
    

    on the server side, respond with content-type text/html and with the following string (this example is done with ExpressJS):

    var domain = req.body.domain,
        script = '',
        body = '' + JSON.stringify({success: true}) + '';
    
    res.send('' + script + '' + body + '');
    

    Update: 19/05/2016

    Actually, the best solution is to do reverse proxy, avoiding this kind of problems.

提交回复
热议问题