I am looking to implement client-side validation for file size. The current code only handles success, but I also want to address file size limitations. Right now, if a file exceeds 2MB, it results in a 500 (Internal Server Error) behind the scenes.
Is there a way to manually handle this and display an error message such as "Max file size should be 2MB"?
Thank you in advance
Note: The snippet below is written in AngularJS
file.upload(url, function(data) {
if(data.success !== true) {
$scope.$apply(function() {
$scope.design.pdf.status = '';
$scope.errors.pdf = data.data;
});
return;
}
$scope.$apply(function() {
$scope.design.pdf = {
status: 'uploaded',
file: data.data.name,
name: data.data.original,
size: data.data.size
}
});
});