You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: validation.md
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1479,7 +1479,10 @@ The field under validation must contain a valid color value in [hexadecimal](htt
1479
1479
<aname="rule-image"></a>
1480
1480
#### image
1481
1481
1482
-
The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp).
1482
+
The file under validation must be an image (jpg, jpeg, png, bmp, gif, or webp).
1483
+
1484
+
> [!WARNING]
1485
+
> By default, the image rule does not allow SVG files due to the possibility of XSS vulnerabilities. If you need to allow SVG files, you may provide the `allow_svg` directive to the `image` rule (`image:allow_svg`).
1483
1486
1484
1487
<aname="rule-in"></a>
1485
1488
#### in:_foo_,_bar_,...
@@ -2202,7 +2205,9 @@ Laravel provides a variety of validation rules that may be used to validate uplo
2202
2205
],
2203
2206
]);
2204
2207
2205
-
If your application accepts images uploaded by your users, you may use the `File` rule's `image` constructor method to indicate that the uploaded file should be an image. In addition, the `dimensions` rule may be used to limit the dimensions of the image:
2208
+
If your application accepts images uploaded by your users, you may use the `File` rule's `image` constructor method to ensure that the file under validation is an image (jpg, jpeg, png, bmp, gif, or webp).
2209
+
2210
+
In addition, the `dimensions` rule may be used to limit the dimensions of the image:
2206
2211
2207
2212
use Illuminate\Support\Facades\Validator;
2208
2213
use Illuminate\Validation\Rule;
@@ -2221,6 +2226,9 @@ If your application accepts images uploaded by your users, you may use the `File
2221
2226
> [!NOTE]
2222
2227
> More information regarding validating image dimensions may be found in the [dimension rule documentation](#rule-dimensions).
2223
2228
2229
+
> [!WARNING]
2230
+
> By default, the `image` rule does not allow SVG files due to the possibility of XSS vulnerabilities. If you need to allow SVG files, you may pass `allowSvg: true` to the `image` rule: `File::image(allowSvg: true)`.
0 commit comments