0

Uploaded files unable to see in the carousel, Im able to see video and image files, please suggest me to see all formats of the docs as well.

  mydata = []
  onSelectFile(event) {
    const files = event.target.files;
    if (files) {
      for (const file of files) {
        const reader = new FileReader();
        reader.onload = (e: any) => {
          if (file.type.indexOf("image") > -1) {
            this.mydata.push({
              url:e.target.result,
              type: 'img'
            });
          } else if (file.type.indexOf("video") > -1) {
            this.mydata.push({
              url:e.target.result,
              type: 'video'
            });
          }else if (file.type.indexOf("ppt") > -1) {
               this.mydata.push({
              url:e.target.result,
             type: 'ppt'
        });
      }

        };
        reader.readAsDataURL(file);
      }
    }
  }

Stackblitz

Rajasekhar
  • 2,215
  • 3
  • 23
  • 38

1 Answers1

0

In the HTML template (on stackblitz) you are referencing an for the PDF document. According to documentation from Mozilla you have to add the type of document as well. So in this case (pdf) you have to specify:

<object *ngIf="list.type == 'pdf'" [data]="list.url" type="application/pdf"></object>

Then the PDF gets rendered. For other types of documents you have to specify the correct type (see docs).

Charlie V
  • 980
  • 1
  • 6
  • 12