Search code examples
jqueryasp.net-mvc-4file-uploadblueimp

Jquery File Upload: Configuring the maxFileSize and AcceptFileTypes


Beginner: I am using the Jquery File upload plugin (backload) from blueimp to create a file uploader and wanted to configure the maxFileSize and Accept File Size options of File upload.

i can either set them up in jquery-fileupload-validate or while initializing the fileupload widget as:

$('#fileupload').fileupload({
   maxFileSize: 500000,
   acceptFileTypes: /(\.|\/)(doc|docx?g|png)$/i,
  ....
})

I am using MVC4 razor and wanted to make this configurable through a config, so that it can be changed without changing the code.

I have some model properties created and wanted to see the various way i can do it like by creating a config file or if there is a way to use the web config or backload config?


Solution

  • Added appsettings in the web.config and added two model properties to get the values in the javascript.

    we are also doing server side validations to avoid any security attacks