onBuildItemForm in filereader onLoad function #532

Open
opened 2016-12-13 20:19:11 +00:00 by vdevarapalli · 0 comments
vdevarapalli commented 2016-12-13 20:19:11 +00:00 (Migrated from github.com)

i am converting selected file to BinaryString using fileReader onload function.

can i call this.uploader.onBuildItemForm in fileReader onload function,.

<input type="file" ng2FileSelect [uploader]="uploader" id="fileUpload" (change) = "handleFileSelect($event)"/>

public uploader:FileUploader = new FileUploader({url:'http://localhost:8080/new',
autoUpload: true,
allowedMimeType: ['image/png', 'image/jpg', 'image/bmp', 'application/pdf'],
maxFileSize: 510241024 // 5 MB
});

handleFileUpload(selectedFile):void {
let fileReader = new FileReader();
fileReader.onload = () => {
this.imageStream = btoa(fileReader.result);
}
fileReader.readAsBinaryString(selectedFile);
fileReader.onloadend = () => {
setTimeout(() => {
this.uploader.onBuildItemForm = (item, form) => {
console.log('..............' + this.imageStream);
form.append("blob", this.imageStream);
};
}, 5000);
}
}

Please Help me.... i am stuck here

i am converting selected file to BinaryString using fileReader onload function. can i call **this.uploader.onBuildItemForm** in fileReader onload function,. <input type="file" ng2FileSelect [uploader]="uploader" id="fileUpload" (change) = "handleFileSelect($event)"/> public uploader:FileUploader = new FileUploader({url:'http://localhost:8080/new', autoUpload: true, allowedMimeType: ['image/png', 'image/jpg', 'image/bmp', 'application/pdf'], maxFileSize: 5*1024*1024 // 5 MB }); handleFileUpload(selectedFile):void { let fileReader = new FileReader(); fileReader.onload = () => { this.imageStream = btoa(fileReader.result); } fileReader.readAsBinaryString(selectedFile); fileReader.onloadend = () => { setTimeout(() => { this.uploader.onBuildItemForm = (item, form) => { console.log('..............' + this.imageStream); form.append("blob", this.imageStream); }; }, 5000); } } Please Help me.... i am stuck here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#532