I have an html <input type="file"
and I am sending chosen file using ajax, In my server side script i have limited file size upto 2MB and if it exceed the limit I am sending a simple message back to client so the client could understand what happend,
server-side script:
@MultipartConfig(
maxFileSize=1024*2048 // 1Mb max
)
try{
MultipartRequest multipartRequest = new MultipartRequest(request, "D:\\");
} catch(IOException e){
out.print("File limit has been exceeded");
}
out.print("Successfully Uploaded");
client-side send script:
if(formdata){
$.ajax({
url: '../propicuploader',
type: 'POST',
data: formdata,
processData: false,
contentType: false,
success: function(data){
alert(data);
}
});
}
The problem is that if the file is lower than 2MB alert box pops in client saying Successfully uploaded
but if it is higher than 2MB then nothing happen although I have in my server-side script Exception to send a file limit exceed error
and don't get the pop up box saying about the error in my client-side. Just guessed and I thought The problem might be ajax that server sends the error at exact time where ajax is posting the data, so can you tell me what is the appropriate way to send file limit exceeded error to client