Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] Highlight extensions instead of mimeTypes for File constraint #20893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
benito103e authored and xabbuh committed May 18, 2025
commit 3474a09b856214ca239af989d221faa05fe69c4a
7 changes: 2 additions & 5 deletions 7 controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ so Symfony doesn't try to get/set its value from the related entity::
'constraints' => [
new File([
'maxSize' => '1024k',
'mimeTypes' => [
'application/pdf',
'application/x-pdf',
],
'mimeTypesMessage' => 'Please upload a valid PDF document',
'extensions' => ['pdf'],
'extensionsMessage' => 'Please upload a valid PDF document',
])
],
])
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.