Hi all,
I'm developing an small JQ-App using igUpload. For the first upload (Pictures) I need a maxFileSizeLimit of 4MB. The second upload (Video) allows 20MB.
I have set the key maxFileSizeLimit in web.config. So how can I set this value (maxFileSizeLimit) depending on the filetype?
Regards Manfred
Hi Petko,
that's exactly what I'm looking for.
Thank you very much.
Best regards
Manfred
Hi Mani,
Thank you for posting in our forums! You can’t change the value of the option in the web.config. You can set the maximum file size and then you can check the file size and cancel the upload if the file is too big. There are two ways of accomplishing this – on the server and on the client side. I recommend you to do it on the server side because of the risk of security issues on the client side. First you have to handle UploadStarting event (you can find information about handling server side events here). In the event handler you can check the file type and the size and if it doesn’t match your criteria you cancel the event. The code below is a simple example:
internal static void IgUpload_UploadStarting(object sender, UploadStartingEventArgs e) { if (e.FileName.Contains(".jpg") && e.FileSize >= 2097152) { e.Cancel = true; } }
Please let me know if you have any further questions!
Kind regards, Petko Zhekov Senior Software Engineer