The uploader.queue is empty when uploading #878
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello guys,
I'm very new in Angularjs and doing an example with upload file using ng2-file-upload
I'm following the content at http://valor-software.com/ng2-file-upload/
My example is simple with just only one input file and one button
html template:
<input type="file" ng2FileSelect [uploader]="uploader"/>
<input type="button" (click)="uploader.uploadAll()" value="UPLOAD"/>
ts file:
import { Component, Directive } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'app-upload',
templateUrl: '../views/ng2-file-uploader.html',
})
export class ImageUploadComponent {
public uploader:FileUploader = new FileUploader({
url: 'https://evening-anchorage-3159.herokuapp.com/api/',
allowedMimeType: ['image/png'],
maxFileSize: 1024*1024,
autoUpload: false,
isHTML5: true,
});
}
But when I select an image the click on UPLOAD button, the program doesn't call to any API
I did a debug at the code of ng2-file-upload.js and realize that this.queue.length is 0
Hi,
I had the same issue and it was because of the allowedFileType:
private uploader: FileUploader = new FileUploader({ url: URL, queueLimit: 1, allowedFileType: ["jpg", "jpeg", "png"] });
While I was browsing for a pdf file, so it wasn't added to the queue.
@ifindthanh Please check your maxFileSize. It has to contain a number (in MB) and not the img size.
@RaniaShady your allowedFileType array wrong. Allowed file types are not the extensions. They're defined here: https://github.com/valor-software/ng2-file-upload/issues/696#issuecomment-288531528