【问题标题】:Unable to Upload picture that has been taken by camera. using apache cordova and visual studio无法上传相机拍摄的照片。使用 apache cordova 和 Visual Studio
【发布时间】:2018-12-30 09:19:49
【问题描述】:

您好,我正在使用 Visual Studio 2017。

并且代码是用 Apache cordova 编写的。 我正在使用通过visual studio 2017 config.xml 编辑器添加的两个cordova 标准插件。

我遵循与文档建议相同的代码。 但在 Visual Studio 2017 模拟器中出现以下错误。

为什么我需要使用这个回调编辑器。文件上传的天气api url已经在线了吗?

这是我的代码,毫无例外地被执行。

   var win = function (r) {
            navigator.camera.cleanup();
            retries = 0;
            alert('Done!');
        }

        var fail = function (error) {
            if (retries == 0) {
                retries++
                setTimeout(function () {
                    $("#btnUploadPicture").trigger("click");
                }, 1000)
            } else {
                retries = 0;
                navigator.camera.cleanup();
                alert('Ups. Something wrong happens!');
            }
        }

        var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = $("#txtIMEI").html();
        options.mimeType = "image/jpeg";
        options.params = {}; // if we need to send parameters to the server request
        var ft = new FileTransfer();
        ft.upload(fileURI, encodeURI("http://localhost:3199/api/Vehicles"), win, fail, options) 

【问题讨论】:

    标签: cordova cross-platform visual-studio-cordova


    【解决方案1】:

    您正在使用 Ripple 模拟器?我会尽可能远离它。在真实设备或真正的 Android 模拟器中尝试并报告错误是否仍然存在...您可以在 VS 在设备或模拟器上运行时进行调试。

    【讨论】:

    • 你好 @andreszs 我正在使用 Visual Studio Android 模拟器。问题仍然存在于模拟器中。我确实使用了网络浏览器模拟。出于开发人员的目的,而不是将其安装在实际设备上,以便完成工作。但这个问题一直存在。无论如何,谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多