zoukankan      html  css  js  c++  java
  • ant design Upload组件上传文件类型

    参考: https://blog.csdn.net/jyn15159/article/details/108833869

    或 参考: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept

    自己项目里面:

      const onChange = (info) => {
        // if (info.file.status !== 'uploading') {
        //   console.log(info.file, info.fileList);
        // }
        if (info.file.status === 'done') {
          message.success(`${info.file.response.message}` || `${info.file.name}文件导入成功`);
        } else if (info.file.status === 'error') {
          message.error(`${info.file.name}文件导入失败`);
        }
      };
      // const beforeUpload = (file) => {
      //   const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
      //   if (!isJpgOrPng) {
      //     message.error('只能上传Excle文件');
      //   }
      //   const isLt2M = file.size / 1024 / 1024 < 2;
      //   if (!isLt2M) {
      //     message.error('Image must smaller than 2MB!');
      //   }
      //   return isJpgOrPng && isLt2M;
      // };
      const [prop] = useState({
        name: 'file',
        showUploadList: false,
        // beforeUpload: beforeUpload,
        onChange: onChange,
        action: `/api/hotel/lock/room_code/import?hotel_group_id=${JSON.parse(sessionStorage.getItem('currentUser')).hotel_group_id}&hotel_id=${JSON.parse(sessionStorage.getItem('currentUser')).hotel_id}&modify_user=${JSON.parse(sessionStorage.getItem('currentUser')).id}`,
        headers: {
          authorization: 'authorization-text',
        },
        accept: "application/vnd.ms-excel" || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      });
    

      

  • 相关阅读:
    纯CSS实现自动轮播,CSS变量的定义与使用,计算属性的使用
    input:file样式怎样修改
    Div转为Canvas简直不要太好玩~~~
    oracle nvl2函数
    oracle 子查询
    oracle 分组函数执行分析
    oracle外部表
    oracle USING 用法
    面向对象进阶
    面向对象基础
  • 原文地址:https://www.cnblogs.com/taxun/p/13813268.html
Copyright © 2011-2022 走看看