Filtering files for Download and Picture

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,
How can I add a filter for  [UIHint("Download")] and  [UIHint("Picture")] like *.jpg, *.bmp,*.pdf, etc . The purpose is to avoid uploading malware. I am using Version 3.80

Please help
4 years ago
sels2005j wrote:
Hi,
How can I add a filter for  [UIHint("Download")] and  [UIHint("Picture")] like *.jpg, *.bmp,*.pdf, etc . The purpose is to avoid uploading malware. I am using Version 3.80

Please help

There is already validation applied for pictures in server side. To apply that on client side you need customization.
NopCommerce uses fineuploader to upload files, which allows to validate files from client side. To apply that, go to Nop.Web > Areas> Admin > Views > Shared > EditorTemplates. Open Picture.cshtml. At the bottom of the file, you can see initialization options. Modify those part like below.

$("#@(clientId)").fineUploader({
    request: {
        endpoint: '@(Url.Content("~/Admin/Picture/AsyncUpload"))'
    },
    template: "@(clientId)-qq-template",
    multiple: false,
    validation: {
        allowedExtensions: ['jpeg', 'jpg', ...],
        sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
    }
})
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.