收藏
回答

rename函数无法正确赋值?

uping:function(e){
        var that=this;
        wx.chooseMessageFile({   //从聊天获取文件,选择后存为临时文件 temp
          count1,
            success(res){
                console.log(res);
                var name="http://store/"+res.tempFiles[0].name;
                wx.saveFile({    //   临时文件转缓存文件    store
                    tempFilePath:res.tempFiles[0].path,
                    success(e){
                        console.log(e);
                        var f_manager =wx.getFileSystemManager();
                        f_manager.rename({   //重命名
                            oidPath:e.savedFilePath, 
                            newPath:name,
                            success(){
                                console.log("改名成功,名为:",name)
                            },
                            fail(m){
                                console.log(m);
                                console.log(e.savedFilePath,name);
                            }
                        });
                    that.update_filelist(that);   
                    }
                })
            }
        })
    }

运行结果如图:

我将savefile的返回值赋给 rename函数的oldpath,运行后报 oldpath 未定义,但在log里能正确显示值 :http://store......... ,请问是为什么?

回答关注问题邀请回答
收藏

2 个回答

  • Admin²⁰²⁰
    Admin²⁰²⁰
    06-26

    oidPath改为oldPath

    06-26
    有用 1
    回复 1
    • 赵正行
      赵正行
      06-26
      感谢感谢,改完后发现权限受限,还得调试下
      06-26
      回复
  • 赵正行
    赵正行
    06-26

    我试过直接choosemessagefile后rename,但报同样的错误。或者有什么其他方式修改文件名吗?

    06-26
    有用
    回复
登录 后发表内容
问题标签