微信小程序上传pdf和显示

引用:https://blog.csdn.net/qq_54027065/article/details/129854339

js 复制代码
     loadResume(){
        let that = this
        uni.showLoading({
          title:"下载中"
        })
        wx.downloadFile({
          url:url,
          success:(res)=>{
            console.log(res,"res11111")
            if (res.statusCode === 200){
              setTimeout(()=>{
                wx.openDocument({
                  filePath: res.tempFilePath,
                  fileType:"pdf"
                })

                // toast("加载成功")
                uni.hideLoading()
              },1000)
            }else{
              toast("文件不存在或者服务器报错")
              setTimeout(()=>{
                uni.hideLoading()
              },1000)
            }
          },
          error:()=>{
            uni.hideLoading()
          },
          finally:()=>{
            // uni.hideLoading()
          }
        })
      },
      uploadResume(){
        console.log("upload resume")
        wx.chooseMessageFile({
          count:1,
          type:"file",
          success:(res)=>{
            console.log(res,"res11")
            let path = res.tempFiles[0].path
            console.log(path,"path")

            var suffix = path.split(".")[1];
            if (suffix !== "pdf"){
              toast("只能上传pdf的文件")
              return
            }


            uni.showLoading({
              title:"上传中",
              mask:true
            })

            wx.uploadFile({
                url:url,
                header:{
                  "Authorization":getToken()
                },
                name:"file",
                filePath:path,
              success:(res)=>{
                  console.log(res,"hehe123")
                  if (res.statusCode === 200){

                    this.form.reviewInfo.resumeUrl = res.data
                    toast("上传成功")

                  }else{
                    toast("上传失败")
                  }

                  setTimeout(()=>{
                    uni.hideLoading()

                  },2000)
              },
              fail:(res)=>{
                toast("上传失败")
                setTimeout(()=>{
                  uni.hideLoading()

                },2000)
              }
            })


          }
        })
      },
相关推荐
恩创软件开发1 天前
创业日常2026-1-8
java·经验分享·微信小程序·小程序
腾讯云云开发2 天前
微信发布AI小程序成长计划:免费云开发资源+1亿token额度!
微信小程序·ai编程·小程序·云开发
ComPDFKit2 天前
ComPDF 与 Aspose:转换 SDK 的全面比较
pdf
优选资源分享2 天前
PDF 电子签章工具 v5.0:全能处理PDF电子签章
pdf
Arvin_Zhang20162 天前
使用python实现从PDF格式的control mapping获取gross die数量
python·pdf
徐同保2 天前
上传文件,在前端用 pdf.js 提取 上传的pdf文件中的图片
前端·javascript·pdf
CodeCraft Studio2 天前
国产化PDF处理控件Spire.PDF教程:使用Python批量自动化将PDF转换为黑白(灰度)
python·pdf·自动化·spire.pdf·文档自动化·pdf开发组件·国产化文档组件
成旭先生2 天前
文档(如word、ppt、pdf等)在线预览解决方案:基于HTML转换的技术实践与对比
pdf·word·powerpoint
m5655bj2 天前
使用 C# 将 RTF 文档转换为 PDF 格式
pdf·c#
FreeBuf_2 天前
黑猫黑客组织通过伪造Notepad++网站传播窃密恶意软件
notepad++