In this scenario, I am configuring a file upload feature using ng2-file-upload where users can drop files into the designated area. At present, I am able to capture the values of the dropped files successfully. However, I encounter an issue as I also want to retrieve the uploaded file value by triggering a button click function. How can I accomplish this? Below is the code snippet:
Please note that I need to access the fileList value.
Currently, I am able to obtain the file list values using the filedropped method, but additionally, I require the ability to fetch the value by clicking a button.
import { Component } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';
const URL = 'https://evening-anchorage-3159.herokuapp.com/api/';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
// Initialization of variables and constants
public uploader:FileUploader = new FileUploader({url: URL});
public hasBaseDropZoneOver:boolean = false;
public selectedFilesArray = [];
private selectedFile;
// Methods for handling file selection, hover effects, etc.
public selectFile(e: any): void {
// Implementation logic
}
public fileOverBase(e: any): void {
// Implementation logic
}
public selectAllFiles(e: any): void {
// Implementation logic
}
public fileDropped(fileList: any): void
{
// Logic for handling dropped files
}
public fileChecked(e: any): void {
// Logic for handling checked files
}
// Method to retrieve file information
getInfo(){
console.log('file info');
}
}
Find the live demo at this URL.