1

In ExtJs I am uploading a file via form.submit.

        if (field.up('form').getForm().isValid()) {
        field.up('form').getForm().submit({
            url: ExtApplication4.util.GlobalVar.urlUploadPositionSheet,
            waitMsg: 'Uploading your file...',
            headers : {
                'Content-Type' : 'text/html'
            },

Error message

{success:false,message:"Blocked a frame with origin "http://localhost:57007" from accessing a cross-origin frame."}

I see there's tons of posts about this... Extjs fileuplaod - cross-origin frame

But even though I am following it I still cannot return success.

Does anyone know where I would put the

response.write('document.domain = "' + params.__domain + '";'); response.write(JSON.stringify({msg: 'Welcome ' + params.name})); response.end(''); 

that is mentioned in the solution. If that is even the solution.

Community
  • 1
  • 1
solarissf
  • 1,199
  • 2
  • 23
  • 58
  • Have you tried building the application and trying again? A form will not upload cross-domain, and I've had the same error resolve if built. If the upload url is localhost/.... and you're testing on localhost:57007/... it will fail. – Jaimee Mar 24 '17 at 19:21
  • i'm not sure what you mean. my extjs application will be on a different domain than the webapi which is where I am uploading the file to. are you saying this is not possible? – solarissf Mar 24 '17 at 19:24
  • Oh, I see. Ext JS form file upload will fail cross-domain. Searching around a bit I see people opting for ajax request instead, and I've found [this(?)](https://www.guaneri.com/index.php/2015/09/17/cross-domain-extjs-file-uploading/). Though I haven't taken this on myself, so I can't be of much help besides searching around with you... sorry! – Jaimee Mar 24 '17 at 20:15
  • i saw that... doesn't seem to help too much but thanks for searching. – solarissf Mar 24 '17 at 20:16

1 Answers1

0

I also encounter this and it turns out that: This solution only work if the two domains

1.belongs to the same parent domain, like http://static.a.com and http://service.a.com

or

2.are with same host name, just different ports, like http://localhost:81 and http://localhost:82

York Chen
  • 744
  • 4
  • 9