【问题标题】:not able to upload file in windows 8 tablet无法在 Windows 8 平板电脑中上传文件
【发布时间】:2014-10-01 17:08:26
【问题描述】:

我正在使用 cordova 3.4.0 将文件从 Windows 8 平板电脑传输到服务器这是我的代码

        var options  = new FileUploadOptions();
        options.fileKey     = "file";                
        options.chunkedMode = true; 
        options.headers = { Connection: "close" };
        options.params      = params;
        options.fileName    = "myimage.jpeg";
        options.httpMethod = "POST";

        options.mimeType    = "image/jpeg"; 

        var ft = new FileTransfer();
        ft.upload(imagePath, encodeURI("http://192.100.200.1/Files/upload.php"), win, fail, options);

但是当媒体传输开始时,它会向我显示以下错误

异常调用本机命令 :: FileTransfer :: 上传 ::exception=WinRTError: 参数不正确。

相同的代码在 android 和 iOS 中都能正常工作。

【问题讨论】:

    标签: javascript cordova windows-phone-8


    【解决方案1】:

    我发现,对于windows 平台,本地path,在您的情况下为imagePath,需要采用ms-appdata:/// 之类的形式,可以通过使用获得

    var imagePath = fileEntry.toURL()
    

    而不是使用

    fileEntry.toInternalURL()
    

    返回类似cdvfile:// 或而不是

    fileEntry.fullPath
    

    返回类似\\path\to\file 的东西。需要注意的是,根据 Cordova 4.0.0 的当前文档,cdvfile:// 应传递给 FileTransfer。 Cordova的windows平台还没有,需要更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-24
      • 2012-05-19
      相关资源
      最近更新 更多