Describe the bug
Uploading a valid JPEG image whose filename has an UPPERCASE extension (e.g. IMG_1234.JPG, PHOTO.JPEG — common for camera/iPhone exports) is rejected with:
The image field must have one of the following extensions: jpg, jpeg, png, gif, bmp, svg, webp.
The file is a genuine JPEG; only the extension case differs. Renaming the extension to lowercase (.jpg) makes the same file upload successfully.
Root cause
packages/Webkul/Core/src/Rules/FileOrImageValidValue.php (~line 95-97):
$extension = $value instanceof UploadedFile
? $value->getClientOriginalExtension() // preserves original case, e.g. "JPG"
: $value->getExtension();
if ($this->allowedExtensions && ! in_array($extension, $this->allowedExtensions, true)) {
$fail('validation.extensions')->translate(['values' => implode(', ', $this->allowedExtensions)]);
return false;
}
IMAGE_ALLOWED_EXTENSIONS is lowercase (['jpg','jpeg','png','gif','bmp','svg','webp']) and the check uses in_array(..., true) (strict, case-sensitive). So "JPG" !== "jpg" → valid images are rejected based purely on extension letter case.
Steps to reproduce
- Take any valid
.jpg image and rename its extension to uppercase .JPG.
- Upload it to a product Image attribute.
- Validation fails with the extensions error above.
- Rename back to lowercase
.jpg → uploads fine.
Expected behavior
Extension comparison should be case-insensitive. A .JPG/.JPEG file should be accepted exactly like .jpg/.jpeg.
Proposed fix
Lowercase the extension before comparison:
$extension = strtolower(
$value instanceof UploadedFile ? $value->getClientOriginalExtension() : $value->getExtension()
);
Environment
- UnoPIM: v2.1.4
- PHP: 8.4
- OS: macOS (local install via
php artisan serve)
Describe the bug
Uploading a valid JPEG image whose filename has an UPPERCASE extension (e.g.
IMG_1234.JPG,PHOTO.JPEG— common for camera/iPhone exports) is rejected with:The file is a genuine JPEG; only the extension case differs. Renaming the extension to lowercase (
.jpg) makes the same file upload successfully.Root cause
packages/Webkul/Core/src/Rules/FileOrImageValidValue.php(~line 95-97):IMAGE_ALLOWED_EXTENSIONSis lowercase (['jpg','jpeg','png','gif','bmp','svg','webp']) and the check usesin_array(..., true)(strict, case-sensitive). So"JPG" !== "jpg"→ valid images are rejected based purely on extension letter case.Steps to reproduce
.jpgimage and rename its extension to uppercase.JPG..jpg→ uploads fine.Expected behavior
Extension comparison should be case-insensitive. A
.JPG/.JPEGfile should be accepted exactly like.jpg/.jpeg.Proposed fix
Lowercase the extension before comparison:
Environment
php artisan serve)