My attempt to upload a file with a size exceeding 1MB is triggering an error regarding its large size. Despite setting the limit to 50 MB, it doesn't seem to be working as expected. Can someone please assist me in figuring out what I am doing incorrectly?
@Component({
moduleId: module.id,
//define the element to be selected from the html structure.
selector: 'NeedAnalysisConsult',
//location of our template rather than writing inline templates.
templateUrl: 'need-analysis-consultation.component.html',
})
export class NeedAnalysisConsultationComponent implements OnInit {
model:any={};
consultationDate: Date;
organisation: string;
devCode:String;
maxFileSize = 50 * 1024 * 1024;
//declare a property called fileuploader and assign it to an instance of a new fileUploader.
//pass in the Url to be uploaded to, and pass the itemAlais, which would be the name of the //file input when sending the post request.
public uploader:FileUploader = new FileUploader({url: URL,isHTML5: true, itemAlias: 'consultation',maxFileSize: this.maxFileSize});
//This is the default title property created by the angular cli. Its responsible for the app works
title = 'app works!';
ngOnInit() {
//override the onAfterAddingfile property of the uploader so it doesn't authenticate with //credentials.
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);
};
//overide the onCompleteItem property of the uploader so we are
//able to deal with the server response.
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);
}
};
}
Having trouble uploading a file larger than 1MB and encountering issues due to its size limitation set at 50MB. Any guidance on where I may be going wrong would be greatly appreciated.