JS FileReader not working in safari it is working fine in chrome

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

I have created function to display image please help on this if you have any alternative solution.

admin.previewImage = function(input,selector) {     if (input.files && input.files[0]) {         var reader = new FileReader();          reader.onload = function (e) {             $(selector).attr('src', e.target.result);         }          reader.readAsDataURL(input.files[0]);     } } 

回答1:

Safari doesn't support for js file reader

So I tried this

https://github.com/dcneiner/Downloadify

It Works for me



回答2:

The file reader is only available in safari 6.0 and unfortunately we cannot use it as it is.
U can use an external plugin to show the preview of image or check the availability of filereader api in your browser if not found bypass it with any other issue handling strategies

if(window.FileReader) { //do this } else { //the browser doesn't support the FileReader Object, so do this }



回答3:

The FileReader API is only available as of Safari 6.0 However, if it's important for you to have this functionality in all browsers, you could test for the availability of the FileReader API: if(window.FileReader) { //do this} else {//the browser doesn't support the FileReader Object, so do this}



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