简体   繁体   中英

is there any way to upload the .ply,.stl,.obj file in angular using drag n drop?

Here my issue is that I want to upload the .ply, .stl, .obj say 3d models in angular. Currently I am using the ng2-upload plugin for drag'n'drop which is not supporting these file types. Whenever the file is uploaded it is not getting the mime type.

Below is my code:

 imga = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/256/Button-Upload-icon.png";



       public uploader:FileUploader = new FileUploader({url: URL});
          public hasBaseDropZoneOver:boolean = false;
          public hasAnotherDropZoneOver:boolean = false;
          public selectedFilesArray = [];
          private selectedFile;

        public selectFile(e: any): void {
        var target = e.target || e.srcElement || e.currentTarget;
        var value = target.innerHTML;
        this.selectedFile = value;
        this.selectAll = true;
        this.selectedFilesArray = [];
        this.selectedFilesArray.push(this.selectedFile);

      }
      public fileOverBase(e: any): void {
        this.hasBaseDropZoneOver = e;
      }

        public selectAllFiles(e: any): void {

        this.selectedFilesArray = [];
        if (e.target.checked) {

          this.selectAll = true;

          for (var item in this.uploader.queue) {
            this.selectedFilesArray.push(this.uploader.queue[item].file.name);
          }




        }


      }

I am trying to upload various files using ng2-file-upload and here I am able to upload all the file types like png, jpg etc., except .ply files so how can I upload the files with that extension?

Below is my code:

  imga = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/256/Button-Upload-icon.png";

  public uploader:FileUploader = new FileUploader({url: URL});
  public hasBaseDropZoneOver:boolean = false;
  public hasAnotherDropZoneOver:boolean = false;
  public selectedFilesArray = [];
  private selectedFile;



    public selectFile(e: any): void {
    var target = e.target || e.srcElement || e.currentTarget;
    var value = target.innerHTML;
    this.selectedFile = value;
    this.selectAll = true;
    this.selectedFilesArray = [];
    this.selectedFilesArray.push(this.selectedFile);

  }
  public fileOverBase(e: any): void {
    this.hasBaseDropZoneOver = e;
  }

    public selectAllFiles(e: any): void {

    this.selectedFilesArray = [];
    if (e.target.checked) {

      this.selectAll = true;

      for (var item in this.uploader.queue) {
        this.selectedFilesArray.push(this.uploader.queue[item].file.name);
      }




    }


  }

Below is my stackblitz url: https://stackblitz.com/edit/angular-r6cbrj

ply is not a recognized MIME type by ng2-file-upload . You can find all the supported MIME types in the source code here:

https://github.com/valor-software/ng2-file-upload/blob/development/src/file-upload/file-type.class.ts

as you can see, the content type is set to application for non-listed file extensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM