【问题标题】:How to disable photo library and icloud selection on file input in ipad如何在 ipad 中的文件输入上禁用照片库和 icloud 选择
【发布时间】:2018-01-25 06:41:14
【问题描述】:

只是闲逛,可以用jquery或html在ipad中禁用照片库和icloud选择文件吗?

单击按钮时,我有以下 html 代码用于附加文件:

<input type="file" id="uploadBtn" class="uploadBtn">

目前,如果我在 ipad 中运行代码,当点击附加按钮时,它会弹出一个对话框,允许用户拍照、从照片库或 icould 中选择。无论如何,我可以使用 jquery ot html 在 ipad 中的文件输入上禁用照片库和 icloud 选择?

【问题讨论】:

  • 明确一点,你想强制用户拍照吗?或者你会允许其他应用程序,而不是照片库和 icloud?
  • @Milk 如果页面在 ipad 中打开,则强制其拍照。

标签: jquery html


【解决方案1】:

您无法通过input 按钮执行此操作。

您的替代方法是通过网页上的摄像头拍摄图像,如下所示,然后将图像推送到您的服务器。

HTML

<video id="video" width="640" height="480" autoplay></video>
<button id="snap">Snap Photo</button>
<canvas id="canvas" width="640" height="480"></canvas>

Javascript

// Grab elements, create settings, etc.
var video = document.getElementById('video');

// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
    // Not adding `{ audio: true }` since we only want video now
    navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
        video.src = window.URL.createObjectURL(stream);
        video.play();
    });
}

// Elements for taking the snapshot
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var video = document.getElementById('video');

// Trigger photo take
document.getElementById("snap").addEventListener("click", function() {
    context.drawImage(video, 0, 0, 640, 480);
});

来源:https://davidwalsh.name/browser-camera

【讨论】:

    猜你喜欢
    • 2013-07-23
    • 1970-01-01
    • 2016-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 2014-09-20
    相关资源
    最近更新 更多