Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 930f166

Browse files
authoredApr 16, 2025··
Highligh 'extensions' instead of 'mimeTypes' for File constraint
You should always use the extensions option instead of mimeTypes except if you explicitly don't want to check that the extension of the file is consistent with its content (this can be a security issue). By default, the extensions option also checks the media type of the file.
1 parent 4987fe5 commit 930f166

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
 

‎controller/upload_file.rst

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ so Symfony doesn't try to get/set its value from the related entity::
7777
'constraints' => [
7878
new File([
7979
'maxSize' => '1024k',
80-
'mimeTypes' => [
81-
'application/pdf',
82-
'application/x-pdf',
83-
],
84-
'mimeTypesMessage' => 'Please upload a valid PDF document',
80+
'extensions' => ['pdf'],
81+
'extensionsMessage' => 'Please upload a valid PDF document',
8582
])
8683
],
8784
])

0 commit comments

Comments
 (0)
Please sign in to comment.