A free open source IT asset/license management system
Use config file for file types/mimes
snipe3e9098907a38
diff --git a/app/Http/Requests/UploadFileRequest.php b/app/Http/Requests/UploadFileRequest.phpindex 0ab5426e38..2cb8ff0008 100644--- a/app/Http/Requests/UploadFileRequest.php+++ b/app/Http/Requests/UploadFileRequest.php@@ -31,7 +31,7 @@ class UploadFileRequest extends Request$max_file_size = Helper::file_upload_max_size();return [- 'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,json,webp,avif|max:'.$max_file_size,+ 'file.*' => 'required|mimes:'.config('filesystems.allowed_upload_extensions_for_validator').'|max:'.$max_file_size,];}diff --git a/config/filesystems.php b/config/filesystems.phpindex 50b2675589..2aae01c055 100644--- a/config/filesystems.php+++ b/config/filesystems.php@@ -99,10 +99,67 @@ $config = [],+];// copy the selected PUBLIC_FILESYSTEM_DISK's configuration to the 'public' key for easy use// (by default, the PUBLIC_FILESYSTEM DISK is 'local_public', in the public/uploads directory)$config['disks']['public'] = $config['disks'][env('PUBLIC_FILESYSTEM_DISK','local_public')];+// This is used to determine which files to accept, and also to populate the language strings for the upload-file blade+$config['allowed_upload_extensions_array'] = [+ 'avif',+ 'doc',+ 'doc',+ 'docx',+ 'docx',+ 'gif',+ 'ico',+ 'jpeg',+ 'jpg',+ 'json',+ 'key',+ 'lic',+ 'mov',+ 'mp3',+ 'mp4',+ 'ogg',+ 'pdf',+ 'png',+ 'rar',+ 'rtf',+ 'svg',+ 'txt',+ 'wav',+ 'webm',+ 'webp',+ 'xls',+ 'xlsx',+ 'xml',+ 'zip',+];++++$config['allowed_upload_mimetypes_array'] = [+ 'application/json',+ 'application/msword',+ 'application/pdf',+ 'application/vnd.ms-excel',+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',+ 'application/x-rar-compressed',+ 'application/zip',+ 'audio/*',+ 'image/*',+ 'text/plain',+ 'text/rtf',+ 'text/xml',+ 'video/*',+];++$config['allowed_upload_mimetypes'] = implode(',', $config['allowed_upload_mimetypes_array']);+$config['allowed_upload_extensions_for_validator'] = implode(',', $config['allowed_upload_extensions_array']);+$config['allowed_upload_extensions'] = '.'.implode(', .', $config['allowed_upload_extensions_array']);+return $config;\ No newline at end of filediff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.phpindex 138232b6b3..f41afdc500 100644--- a/resources/lang/en-US/general.php+++ b/resources/lang/en-US/general.php@@ -311,7 +311,7 @@ return ['username' => 'Username','update' => 'Update','updating_item' => 'Updating :item',- 'upload_filetypes_help' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, xls, xlsx, txt, lic, xml, zip, rtf and rar. Max upload size allowed is :size.',+ 'upload_filetypes_help' => 'Allowed filetypes are: :allowed_filetypes. Max upload size allowed is :size.','uploaded' => 'Uploaded','user' => 'User','accepted' => 'accepted',diff --git a/resources/views/modals/upload-file.blade.php b/resources/views/modals/upload-file.blade.phpindex caeac9a761..a4738286d1 100644--- a/resources/views/modals/upload-file.blade.php+++ b/resources/views/modals/upload-file.blade.php@@ -21,7 +21,7 @@<label class="btn btn-default btn-block">{{ trans('button.select_files') }}- <input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf,application/json" style="display:none" required>+ <input type="file" name="file[]" multiple class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="{{ config('filesystems.allowed_upload_mimetypes') }}" style="display:none" required></label></div>@@ -29,7 +29,7 @@<span id="uploadFile-info"></span></div><div class="col-md-12">- <p class="help-block" id="uploadFile-status">{{ trans('general.upload_filetypes_help', ['size' => Helper::file_upload_max_size_readable()]) }}</p>+ <p class="help-block" id="uploadFile-status">{{ trans('general.upload_filetypes_help', ['allowed_filetypes' => config('filesystems.allowed_upload_extensions'), 'size' => Helper::file_upload_max_size_readable()]) }}</p></div><div class="col-md-12">