Fix file extension validation to use original filename #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
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?
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.