Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions docs/en/core-libraries/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,21 @@ Core rules that take additional parameters should have an array for the
`rule` key that contains the rule as the first element, and the additional
parameters as the remaining parameters.

### File Extensions

`Validation::extension()` accepts `gif`, `jpeg`, `png`, `jpg`, `jxl`, `webp`,
`avif` and `avifs` by default. Supply an explicit list to restrict extensions
for a particular upload:

```php
$validator->add('photo', 'extension', [
'rule' => ['extension', ['jpg', 'jpeg', 'png']],
]);
```

The rule checks the filename extension, not the file's contents. Use a MIME
type rule as well when you need to check the uploaded content.

### IP and Range Validation

You can validate that a value is a valid IP address or an IP range (subnet)
Expand Down
3 changes: 2 additions & 1 deletion docs/en/views/helpers/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,8 @@ You could then use JavaScript to set the `onvalid` and `oninvalid` events as you

Creates an `input` element of `submit` type, with `$caption` as value.
If the supplied `$caption` is a URL pointing to an image (i.e. if the string
contains '://' or contains any of the extensions '.jpg, .jpe, .jpeg, .gif'),
contains '://' or ends in `.jpg`, `.jpe`, `.jpeg`, `.jxl`, `.gif`, `.png`,
`.webp`, `.ico`, `.avif` or `.avifs`),
an image submit button will be generated, using the specified image if it
exists. If the first character is '/' then the image path is relative to
*webroot*, else if the first character is not '/' then the image path is
Expand Down
Loading