zoukankan      html  css  js  c++  java
  • vue element 上传图片 文件

     handleAlbumSuccess1(file){
      //判断文件类型 
    const typeList = ["pdf", "xls","xlsx"];
    const errMsg = '请上传excel文件'
    var tag=this.beforeUpload(file,typeList,errMsg)
      if(tag){
      console.log(file)
      this.file=file
      let formdata=new FormData()
      formdata.append("file",file)
      axios.post("http://115.28.211.100:8002/uploadImage",formdata,{
         headers: {
           'Content-Type': 'multipart/form-data'
           }
           }).then(res=>{
        console.log(res.data)
        this.tableData.productEdition=res.data
        this.fileList1.push({
          name:res.data.substring(res.data.lastIndexOf('/')+1),
          path:res.data
        })
      })}
      },
       //删除图片   
      handleRemove1(file, fileList) {
        this.fileList1.splice(this.fileList1.findIndex(item => item === file), 1)
        console.log(file, fileList);
      },
      beforeRemove1(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }?`);
      },
      // 检查 文件类型
      beforeUpload(file,arr = [],mssage){
      const typeList = [...arr];
      const fileName = file.name;
      const extension = fileName.substr(fileName.lastIndexOf(".") + 1);
      const isRT = typeList.includes(extension);
        if (!isRT) {
              this.$message.error('请上传正确的文件类型');
        }
        return isRT;
    }
    ```*
  • 相关阅读:
    mac 命令大全
    GAME OF THRONES 2
    GAME OF THRONES 1
    软件工程-作业一
    猜数字游戏
    摘自-角田光代《对岸的她》
    java复习总结
    艾米莉-狄金森
    初次接触软件工程
    Environment/reflection mapping & bump mapping
  • 原文地址:https://www.cnblogs.com/wp980327/p/14429922.html
Copyright © 2011-2022 走看看