nervgh / angular-file-upload

[ALMOST NOT MAINTAINED] Angular File Upload is a module for the AngularJS framework
MIT License
3.44k stars 1.13k forks source link

fix: IE bug when we're uploading from an iframe #876

Open Nowadays opened 3 years ago

Nowadays commented 3 years ago

When using IE and iframes, if we upload a file from the iframe the File object is contructed using the window.parent.File, so checking value instanceof File yields false since it's the equivalent of doing value.constructor === window.File which also yields false since window.parent.File !== window.File

Note: if we're not in an iframe window.parent === window -> true, so no futher checking is necessary

ygj6 commented 3 years ago

I tested the scenario you said, the result is true,can you provide test cases image

Nowadays commented 3 years ago

Just rechecked, this is an even worse edge case :

We're actually using a modal which holds the input that uploads the files in an iframe.

The issue is when you have a modal opened from the iframe BUT bound to the parent DOM (this is a technique to avoid weird issue with modal in iframes).

The issue is only in IE, chrome yields true on value instanceof File in the same scenario.

Sorry for not mentionning the modal, I didn't even think about that at first.

ygj6 commented 3 years ago

Just rechecked, this is an even worse edge case :

We're actually using a modal which holds the input that uploads the files in an iframe.

The issue is when you have a modal opened from the iframe BUT bound to the parent DOM (this is a technique to avoid weird issue with modal in iframes).

The issue is only in IE, chrome yields true on value instanceof File in the same scenario.

Sorry for not mentionning the modal, I didn't even think about that at first.

I uploaded a use case to demonstrate this problem: examples/issues/pr876 But the result is true.

The picture below is the page I visited using IE11 browser, the button in the page opened a modal,there is an iframe in the modal box, there is an uploads input in the iframe, the final result is true

If I misunderstood what you meant, help improve this use case,thx. image