【问题标题】:how to open the camera from browser and save the image in local directory for Cordova如何从浏览器打开相机并将图像保存在 Cordova 的本地目录中
【发布时间】:2018-11-30 00:48:21
【问题描述】:

我有一个从浏览器打开相机的代码。如何改进此代码以便我可以将文件保存在本地目录中。

document.getElementById('takephoto').onclick = function(){
    console.log(navigator.camera);
    navigator.camera.getPicture(function(imageUri){
        var lastphoto = document.getElementById("thephoto");
        alert("nicephoto");
        lastphoto.innerHTML = "<img src='" + imageUri + "'style='width:100%;'/>"
    }, null, null);

}

使用此代码我可以访问相机

【问题讨论】:

    标签: jquery cordova cordova-plugin-camera


    【解决方案1】:

    尝试使用它,看看是否有帮助

      document.getElementById('takephoto').onclick = function(){
            console.log(navigator.camera);
            navigator.camera.getPicture(function(imageUri){
                var lastphoto = document.getElementById("thephoto");
                alert("nicephoto");
                lastphoto.innerHTML = "<img src='" + imageUri + "'style='width:100%;'/>";
                var a = document.createElement("a"),
                    url = URL.createObjectURL(file);
                a.href = url;
                a.download = filename;
                document.body.appendChild(a);
                a.click();
                setTimeout(function() {
                 document.body.removeChild(a);
                  window.URL.revokeObjectURL(url);  
                }, 0); 
                download(imageUri, "someFilename.jpg", "image");
            }, null, null);
    
        }
    

    【讨论】:

      猜你喜欢
      • 2014-10-26
      • 2013-07-18
      • 1970-01-01
      • 1970-01-01
      • 2014-11-12
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多