FileReader API working in jsFiddle, but not from local file

↘锁芯ラ 提交于 2019-12-19 04:13:05

问题


I'm working on a Chrome/Firefox extension which will be using the file API to store files locally. I'm trying to get an example up and running but I'm running into issues which seem to center around Chrome. Can anyone explain why this jsFiddle works fine, but the exact same code, when run from a local file, doesn't work. Please note that it works fine in Firefox, just not in Chrome. Any ideas?


回答1:


Chrome has unusually restrictive web security; many things, like Ajax, won't work when run locally. This is one of them. You can get around this problem by either using a local websever, like @ephemient suggests, or you can run Chrome in unsafe mode for testing:

chrome.exe --disable-web-security



回答2:


Yep. Chrome's SOP prevents just about everything in file:// from working[1]. Use a local webserver instead.




回答3:


If you are using chrome. Start the chrome from command line with the flag --allow-file-access-from-files chrome doesn't support for accessing local file without this flag.



来源:https://stackoverflow.com/questions/9745568/filereader-api-working-in-jsfiddle-but-not-from-local-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!