downloadFile:fail permission denied, ope
发布于 5 年前 作者 ppeng 6501 次浏览 来自 问答

wx.downloadFile({

url: https://piggy.com/res/atlas/images2d6983f.atlas,

header: {

‘content-type’: ‘image/png’,

},

filePath: “./res”,

success: function (res) {

console.log(“1111”, res)

},

fail: function (res) {

console.log(“2222”, res)

}

})

filePath使用相对路径,相对于当前的JS文件所在的目录的下一子目录 res, 所以使用了filePath:"./res"

但报downloadFile:fail permission denied, open “./res”", statusCode: 200}

想要把

是没有权限打开这个res目录呢?还是根本都找不到。

求教wx.downloadFile正确用法

5 回复

我也等官方回复

请问题主解决这个问题了吗

看到过去这么久了,还有很多同学没找到解决方案,在这里贴上正确的用法。注意粗体字。

统一回复:

var tmp1 = wx.downloadFile({

  url: “https://piggy.q1.com/res/atlas/imagescp2f660bd4.png”,

  header: {

    ‘content-type’: ‘application/json’,

  },

  filePath: wx.env.USER_DATA_PATH + “/res”,

  success: function (res) {

    console.log(“1111”, res)

  },

  fail: function (res) {

    console.log(“2222”, res)

    console.log(“TTTTTTT”, tmp1)

  }

})

我想保存在其他路径 应该怎么弄,比如桌面

请核对文档说明,downloadFile参数哪里有filePath这个downloadFile得到是一个临时文件路径

回到顶部