首页 > 解决方案 > HTML File image input is blank screen on iPhone using Chrome

问题描述

I am using the following code to accept image input in my website

<input type="file" id="qrFile" accept="image/*" />

On Chrome in Android it works fine but on iPhone in Chrome I get this. Any idea why it won't work on Chrome on the iPhone?

enter image description here

标签: htmlgoogle-chromefile-io

解决方案


尝试这个

<input id="myFileInput" type="file" accept="image/*;capture=camera">

var myInput = document.getElementById('myFileInput');

function sendPic() {
    var file = myInput.files[0];

// Send file here either by adding it to a `FormData` object 
// and sending that via XHR, or by simply passing the file into 
// the `send` method of an XHR instance.
}

myInput.addEventListener('change', sendPic, false);

推荐阅读