Having issue with my code - I can't upload a file larger than 1mb even though maxFileSize is set to 50mb. Can anyone help me troubleshoot?
@Component({
moduleId: module.id,
selector: 'NeedAnalysisConsult',
templateUrl: 'need-analysis-consultation.component.html',
})
export class NeedAnalysisConsultationComponent implements OnInit {
model:any={};
consultationDate: Date;
organisation: string;
devCode:String;
maxFileSize = 50 * 1024 * 1024;
public uploader:FileUploader = new FileUploader({url: URL,isHTML5: true, itemAlias: 'consultation',maxFileSize: this.maxFileSize});
title = 'app works!';
ngOnInit() {
this.uploader.onAfterAddingFile = (file)=> { file.withCredentials = false; };
this.uploader.onBuildItemForm=(item:any,form:any)=>{
form.append('devCode',this.model.programmeCode);
form.append('date',this.model.consultationDate);
form.append('organization',this.model.organisation);
};
this.uploader.onCompleteItem = (item:any, response:any, status:any, headers:any) => {
console.log("FileUpload: successfully uploaded:", item, status, response);
if (status==201){
alert("FileUpload: successfully");
}
else {
alert("FileUpload:"+response);
}
};
}
constructor(private http: Http, private el: ElementRef,private router:Router,private _location: Location) {
}
@ViewChild('selectedFile') selectedFile: any;
clear(){
this.model.programmeCode="";
this.model.organisation="";
this.model.consultationDate=null;
this.selectedFile.nativeElement.value = '';
(<HTMLInputElement>document.getElementById("file-name")).value = "";
}
updateFile(){
(<HTMLInputElement>document.getElementById("file-name")).value = "";
for(var i = 0;i<this.uploader.queue.length;i++){
if(i != 0)
(<HTMLInputElement>document.getElementById("file-name")).value += " ; "+this.uploader.queue[i].file.name;
else
(<HTMLInputElement>document.getElementById("file-name")).value = this.uploader.queue[i].file.name;
console.log(this.uploader.queue[i].file.name);
}
}
close() {
console.log("closing the window...");
this.router.navigate(['/home']);
}
removefile(){
(<HTMLInputElement>document.getElementById("file-name")).value = "";
}
backClicked() {
this._location.back();
}
}
Struggling to figure out why files over 1mb cannot be uploaded despite setting maxFileSize to 50mb in my code. Any advice would be appreciated.