发行与股票浏览器从画廊挑选的照片 [英] Issue with stock Browser picking photos from Gallery

查看:98
本文介绍了发行与股票浏览器从画廊挑选的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作网页上从移动设备上传照片,使用<输入类型=文件接受=图像/ */> 标记。这个精美的作品在iPhone和铬对Android,但在这里我们遇到了问题,与普通的Andr​​oid浏览器。

I am working on a web page for uploading photos from a mobile device, using the <input type="file" accept="image/*"/> tag. This works beautifully on iphone and on chrome on the android, but where we are running into issues is with the stock android browser.

这个问题出现时,您选择从您的画廊文件(当你用相机拍一张照片,它工作正常)。我们已经把范围缩小,甚至还看到了从股票浏览器的画廊拍摄时(下面的照片显示的数据URL的前100个字符被加载的数据MIME类型不可用。我们的目标是迫使JPEG ,但没有MIME类型,我们不能确切知道如何解决这个问题。见下面code如何在图像渲染。

The issue arises when you select a file from your gallery (it works fine when you use the camera to take a photo). And we have narrowed it down even further to seeing that the data MIME type isn't available when taken from the gallery on the stock browser (the photos below show the first 100 characters of the data URL being loaded. The goal was to force JPEG, but without the MIME type we cannot know for sure how to fix this. See code below for how the images are being rendered.

如何图像可以不带类型呈现?更重要的是,没有任何人知道为什么类型不提供股票Android浏览器?

How can an image be rendered without the type? Better yet, does anybody know why the type is not available on the stock android browser?

修改

首先,这是不一样的形象,他们被带到附近的同一时间,这不是问题,这就是为什么数据不同(MIME类型不会出现在对股票浏览器的任何图像,所以这是没问题的。

Firstly, these are not the same image, they were taken near the same time, and that's not the issue, that's why the data is different (The MIME type doesn't appear on any images on the stock browser, so that's not the problem.

更新

我证实,MIME类型是问题通过插入图像/ JPEG流入股市的浏览器的地方是在Chrome。不幸的是,我们没有办法保证,这将是JPEG的,所以我们又真的不能这样做的。

I confirmed that the MIME type is the issue by inserting image/jpeg into the stock browser where it is on chrome. Unfortunately, we have no way of guaranteeing that it's going to be jpeg, so we again really can't do it that way

 _readInputFile: function (file, index) {
            var w = this, o = this.options;
            try {

                var fileReader = new FileReader();

                fileReader.onerror = function (event) {
                    alert(w._translate("There was a problem opening the selected file. For mobile devices, some files created by third-party applications (those that did not ship with the device) may not be standard and cannot be used."))
                    $('#loadingDots').remove();
                    return false;
                }
               fileReader.onload = function (event) {

                var data = event.target.result;
                //alert(data.substring(0,100));
                //var mimeType = data.split(":")[1].split(";")[0];


                alert("Load Image"); //I get to this point
                $('#' + w.disp.idPrefix + 'hiddenImages').append($('<img />', {
                    src: data,
                    id: "dummyImg" + index,
                    load: function(){
                    var width = dummy.width();
                    var height = dummy.height();
                    $('#dummyImg' + index).remove();
                    alert("Render"); // I don't get here
                        var resized = w._resizeAndRenderImage(data, null, null, biOSBugFixRequired, skewRatio, width, height);
                        alert("Image Rendered"); // I don't get here

                    }
                }));
            }
            fileReader.readAsDataURL(file);
        }
        catch (e) {
        }  
 } 

Chrome浏览器

Chrome

库存浏览器

Stock Browser

推荐答案

由于该问题可能是浏览器相关,并不能真正解决浏览器(你可以报告给谷歌,虽然一个bug),我会建议走一条不同的道路。

Since the issue is probably browser-related, and you can't really fix the browser(you could report a bug to Google though), I'd suggest taking a different path.

看一看这里: <一href="http://stackoverflow.com/questions/8473703/in-node-js-given-a-url-how-do-i-check-whether-its-a-jpg-png-gif">In Node.js的,给一个网址,我如何检查其是否为JPG / PNG / GIF?

请参阅接受的答案,这表明一个方法来检查使用文件流的文件类型的评论。我是pretty的肯定这会工作在浏览器中实现的Javascript和不仅在Node.js的。

See the comments of the accepted answer, which suggests a method to check the file type using the file stream. I'm pretty sure this would work on browser-implemented Javascript and not only in Node.js.

这篇关于发行与股票浏览器从画廊挑选的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆