Skip to content

Image upload rejected for uppercase file extensions (.JPG/.JPEG) — strict case-sensitive extension check #502

Description

@IamGPOP

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

  1. Take any valid .jpg image and rename its extension to uppercase .JPG.
  2. Upload it to a product Image attribute.
  3. Validation fails with the extensions error above.
  4. 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)

Activity

  1. moved this from Backlog to Done in v2.xon Jun 17, 2026
  2. added a commit that references this issue on Jun 18, 2026
    995940d
  3. added 2 commits that reference this issue on Jun 19, 2026
    ba5137e
    5aca34d
  4. added a commit that references this issue on Jun 26, 2026
    2bf05de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions