redhog / ep_fileupload

File upload plugin for Etherpad Lite
http://redhog.org/ep_fileupload
7 stars 13 forks source link

ajax file upload using formData with fallback to hidden iframe #27

Open shawwwn opened 5 years ago

shawwwn commented 5 years ago

This PR is to fix the issue with iframe access lockdown by modern browers.

Even though iframe and parent html are under the same origin, browsers without enabling CORS won't be able to modified children iframe's content. Instead, you get errors like:

Blocked a frame with origin xxxxxxxxx from accessing a cross-origin frame.

This PR uses ajax request with simulated form data upload via formData() so to bypass the upload-to-hidden-iframe scheme completely.

For older browser that doesn't support formData(), this PR allows fallbacking to iframe uploading scheme.