Skip to content

Conversation

@screenfluent
Copy link
Contributor

@screenfluent screenfluent commented Nov 22, 2024

The file extension validation was checking the temporary file path which doesn't have an extension. This fix changes it to check the original filename's extension instead, allowing proper validation of uploaded files.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

This PR fixes a bug in file extension validation where the validation was checking the temporary file path instead of the original filename.

Currently, when validating file extensions during upload, the code checks the extension of the temporary file path (e.g., /private/var/tmp/phpqtJu54). Since temporary files don't have extensions, this causes the validation to fail even for valid file types.

The fix changes the validation to check the extension from the original filename ($file['name']) instead of the temporary file path, allowing proper validation of uploaded files.

Testing

Tested by uploading various image files (PNG, JPG, JPEG, GIF) with extension validation enabled. All valid files were accepted successfully.

Does this PR introduce a breaking change?

  • Yes
  • No

Related Issue

No existing issue was found for this bug. The issue was discovered while implementing file uploads with extension validation, where valid image files were being rejected due to the temporary file path being used for extension validation instead of the original filename.

The file extension validation was checking the temporary file path
which doesn't have an extension. This fix changes it to check the
original filename's extension instead, allowing proper validation
of uploaded files.
@mychidarko mychidarko merged commit 7274602 into leafsphp:v2.x Nov 22, 2024
0 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants