Is it possible to preload the p-fileupload control?
-
- Posts: 1
- Joined: 21 Jul 2021, 17: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)?
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)
@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)
-
- Posts: 1
- Joined: 25 Jan 2023, 23:45
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?
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?
-
- Information
-
Who is online
Users browsing this forum: No registered users and 17 guests