How to allow file extensions in Craft CMS
In order to allow file extensions, such as .ai, .indd, .psd, .glb or .usdz, you must add them to extraAllowedFileExtensions in the general.php file.
Craft CMS comes with a lot of out of the box file extensions (listed below) but does not allow ALL file extensions to be uploaded to a backend (i.e. S3).
When you try to attempt a file that is not allowed you will get a message like 'filetype' is not an allowed file extension.
In order to allow extra file extensions that are not allowed by default we must be configure the general.php file to allow for them.
What file extensions are allowed out of the box ?
.7z, .aiff, .asc, .asf, .avi, .avif, .bmp, .cap, .cin, .csv, .dfxp, .doc, .docx, .dotm, .dotx, .fla, .flv, .gif, .gz, .gzip, .itt, .jp2, .jpeg, .jpg, .jpx, .js, .json, .lrc, .m2t, .m4a, .m4v, .mcc, .mid, .mov, .mp3, .mp4, .mpc, .mpeg, .mpg, .mpsub, .ods, .odt, .ogg, .ogv, .pdf, .png, .potx, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx, .ppz, .pxd, .qt, .ram, .rar, .rm, .rmi, .rmvb, .rt, .rtf, .sami, .sbv, .scc, .sdc, .sitd, .smi, .srt, .stl, .sub, .svg, .swf, .sxc, .sxw, .tar, .tds, .tgz, .tif, .tiff, .ttml, .txt, .vob, .vsd, .vtt, .wav, .webm, .webp, .wma, .wmv, .xls, .xlsx, .zip.
How to allow new file extensions
Update the general.php to include extraAllowedFileExtensions along with the file extensions you wish to allow for these to be accepted by the Craft CMS. A sample line that can be added to the config to allow .glb and .usdz is found below.
'extraAllowedFileExtensions' => 'usdz, glb'
In Craft4+ its the following:
->extraAllowedFileExtensions(['usdz', 'glb'])
Once you've added the line, restart your local environment or push changes to be able to upload the file types that you added to your general.php.
Any Questions ?
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.