Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
898
Variable maxFileSizeLimit with igUpload
posted

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

  

Parents
  • 2355
    Verified Answer
    Offline posted

    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

Reply Children
No Data