小程序
小游戏
企业微信
微信支付
扫描小程序码分享
线上小程序,在电脑端打开,如何实现上传附件(如office或压缩文件)。
7 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
目前Windows已实现“拖拽聊天/桌面本地文件进小程序”的功能,可先尝试。近期会支持wx.chooseMessageFile相关接口的优化。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
现在 小程序无法使用chooseMessageFile实现电脑登录小程序上传本地文件,现在这个方式也不可以,不知道使用什么方法可以实现电脑登录小程序上传本地文件
chooseFile: function () { const that = this; const deviceInfo = wx.getDeviceInfoSync?.() || {}; const isPC = ["windows", "mac", "desktop"].includes(deviceInfo.platform) || deviceInfo.deviceType === "desktop"; if (isPC) { wx.chooseFile({ count: 9 - that.data.uploadFiles.length, success: function (res) { that.setData({ uploadFiles: [ ...that.data.uploadFiles, ...res.tempFiles.map((file) => ({ path: file.path, name: file.name.split("/").pop(), type: file.type || "unknown", })), ], }); }, }); } else { // 手机端选择微信文件 wx.chooseMessageFile({ count: 9 - that.data.uploadFiles.length, type: "all", success: function (res) { that.setData({ uploadFiles: [ ...that.data.uploadFiles, ...res.tempFiles.map((file) => ({ path: file.path, name: file.name, type: file.type || "unknown", })), ], }); }, }); } },
chooseMessageFile只是从聊天里选择文件,目前PC端可能不兼容,你这个需求很难实现,可以试试加载网页选择文件,也不容易
如果只是在电脑端上传,可以使用 wx.chooseMessageFile
wx.chooseMessageFile
利用webview,内嵌h5,通过原生组件 <input type='file' />可以实现
本回答由AI生成,可能已过期、失效或不适用于当前情形,请谨慎参考
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
目前Windows已实现“拖拽聊天/桌面本地文件进小程序”的功能,可先尝试。近期会支持wx.chooseMessageFile相关接口的优化。
现在 小程序无法使用chooseMessageFile实现电脑登录小程序上传本地文件,现在这个方式也不可以,不知道使用什么方法可以实现电脑登录小程序上传本地文件
chooseFile: function () { const that = this; const deviceInfo = wx.getDeviceInfoSync?.() || {}; const isPC = ["windows", "mac", "desktop"].includes(deviceInfo.platform) || deviceInfo.deviceType === "desktop"; if (isPC) { wx.chooseFile({ count: 9 - that.data.uploadFiles.length, success: function (res) { that.setData({ uploadFiles: [ ...that.data.uploadFiles, ...res.tempFiles.map((file) => ({ path: file.path, name: file.name.split("/").pop(), type: file.type || "unknown", })), ], }); }, }); } else { // 手机端选择微信文件 wx.chooseMessageFile({ count: 9 - that.data.uploadFiles.length, type: "all", success: function (res) { that.setData({ uploadFiles: [ ...that.data.uploadFiles, ...res.tempFiles.map((file) => ({ path: file.path, name: file.name, type: file.type || "unknown", })), ], }); }, }); } },
chooseMessageFile只是从聊天里选择文件,目前PC端可能不兼容,你这个需求很难实现,可以试试加载网页选择文件,也不容易
如果只是在电脑端上传,可以使用 wx.chooseMessageFile
wx.chooseMessageFile
利用webview,内嵌h5,通过原生组件 <input type='file' />可以实现