innostudio / fileuploader

Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
141 stars 25 forks source link

How to handle CORS #13

Closed matdrapeau closed 7 years ago

matdrapeau commented 7 years ago

I have an issue when using the data-fileuploader-files option with a remote image. I get such error:

Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

I enabled cross origin on the image server but still having this issue. Do you have an idea how to solve this?

thanks

innostudio commented 7 years ago

@matdrapeau thank you for reporting it. We know about this issue and we fixed in the v1.3.

solved by adding img.setAttribute('crossOrigin', 'anonymous'); before img.src = src; in code.

matdrapeau commented 7 years ago

Hello, We did paid for the license and install the 1.3 version. Unfortunately, there is still a perpetual loading icon appearing and this message in the debugger:

Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. at Object.isBlankCanvas (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:40036) at h (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:10403) at h (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:10526) at Array.<anonymous> (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:10908) at u (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:32225) at Image.o.onload (http://localhost:5000/static/js/jquery.fileuploader.min.js:9:33416)

innostudio commented 7 years ago

@matdrapeau as you ca see in the changelog, we added item.data.readerCrossOrigin = 'anonymous' option. That means that your file object should have the following structure: { name: 'filename1.txt', size: 1024, type: 'text/plain', file: 'uploads/filename1.txt', data: { readerCrossOrigin = 'anonymous' } }

matdrapeau commented 7 years ago

@innostudio thanks, that is fixing the loading icon except that the png image is not previewed, it shows a "png" text icon instead.