Search code examples
regexopencartopencart-3

regex for fileupload images only - opencart


I am using Opencart V3 At the time of registration we need user to submit a scan copy of some document. For this we added a new customer file upload field (admin > customers > custom field). Problem is that regex dont seems to work, this is our regex to allow upload of image files only but its allowing all file extensions.

[a-zA-Z_\s0-9:\b]+(\.png|\.jpg|\.jpeg|\.pdf|\.PNG|\.JPG\.JPEG|\.pdf|)$

Solution

  • There is a place in OpenCart to configure allowed file extensions and mime types.

    Go to System - Settings, tab Server. Here you will find Allowed File Extensions and Allowed File Mime Types. Edit them on your discretion.