Is it possible to preload the p-fileupload control?

UI Components for Angular
Post Reply
lightbulb110
Posts: 1
Joined: 21 Jul 2021, 17:50

22 Jul 2021, 15:50

Users are able to upload file using the browse button within the control. However, is it possible to preload the control with a list of files (programmatically)?

bijumenon
Posts: 1
Joined: 18 Feb 2022, 05:29

18 Feb 2022, 05:34

yes it is possible.

@ViewChild('fileInput') fileInput: FileUpload;


this.fileInput.clear();
let blob=null;
blob = new Blob([element.fileContent]);
blob.lastModifiedDate = new Date();
blob.name = element.fileName;
blob.objectURL = this.sanitizer.bypassSecurityTrustUrl((window.URL.createObjectURL(blob)));
this.fileInput.files.push(blob)

JimmyDrake
Posts: 1
Joined: 25 Jan 2023, 23:45

26 Jan 2023, 00:06

I am trying to do the same thing but the FileUpload component seems to convert my file into corrupted format, or/and doesn't display it well (i sent an image bellow).
In resume, i am updating a post with pictures.

my code:
blob = new Blob([picture.byteContent], {type: "image/jpeg"});
blob.lastModifiedDate = new Date();
blob.name = picture.name;
blob.objectURL = this.sanitizer.bypassSecurityTrustUrl((window.URL.createObjectURL(blob)));
this.fileUpload.files.push(blob);

Do you know how should i do to let it works?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests