• ajax文件上传


    softwarePackFileChange() {
          const fileTypes = "exe,rar,zip";
          const fileTypeArray = fileTypes.split(",");
    
          const softwarePackFile = $("#softwarePackFile").get(0).files[0];
          const filePathArray = softwarePackFile.name.toLowerCase().split('.');
          const fileType = filePathArray[filePathArray.length - 1];
          if (_.indexOf(fileTypeArray, fileType) == -1) {
            $WarnMessage(`支持的附件格式【${fileTypes}】,当前格式:${fileType}。`);
            return;
          }
    
          const formData = new window.FormData();
          formData.append("file", softwarePackFile);
          formData.append("versionId", this.versionId);
          formData.append("shelfId", this.shelfId);
    
           $.ajax({
             type: "POST",
             data: formData,
             contentType: false,
             processData: false,
             url: `${$$apiDevOpsPath}/uploadAppPkg`,
             success: response => {
               const message = response.message;
               if (message != undefined) {
                 $WarnMessage(message);
               } else {
                 const shelfVersionAppPkg = response.model;
                 shelfVersionAppPkg.minioHost = response.host;
                 this.$emit("pushAppSoftwarePackage", shelfVersionAppPkg);
               }
             },
           });
       
      }
  • 相关阅读:
    导入导出模块
    jQuery复习
    vue记录
    angular 初探之父子组件之间传递数据
    webpack
    go语言语法记录
    dom元素的滚动(如何实现点击展开更多功能)
    正则回忆录
    Attributes 和 properties区别和联系?
    显示 隐藏DIV的技巧
  • 原文地址:https://www.cnblogs.com/150536FBB/p/13050791.html
Copyright © 2020-2023  润新知