I am using ng2-file-upload for uploading files to my angular2 application. The problem is that when I click on the 'upload' button, I get a 404 (Not Found) error, meaning the directory I set for the uploads is not found. Here is my component:
import { Component } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';
const URL = 'http://localhost:4200/src/app/uploads/';
@Component({
selector: 'upload-file',
templateUrl: 'upload-file.html'
})
export class UploadCvComponent {
uploader: FileUploader = new FileUploader({ url: URL });
hasBaseDropZoneOver: boolean = false;
hasAnotherDropZoneOver: boolean = false;
fileOverBase(e: any): void {
this.hasBaseDropZoneOver = e;
}
fileOverAnother(e: any): void {
this.hasAnotherDropZoneOver = e;
}
}
I created a directory for holding the upload files at /src/app/uploads/. Is there anything else I need to do for this to work, or FileUploader should do the rest of the job? I believe the error I get is because I am using a router for the Angular2 app and that URL (http://localhost:4200/src/app/uploads/) isn't defined in the router.
Can someone please advise? Many thanks!