Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Uploaded SRT files are saved as CSV #3921

Closed
benjaminbellamy opened this issue Nov 24, 2020 · 1 comment · Fixed by #3956
Closed

Bug: Uploaded SRT files are saved as CSV #3921

benjaminbellamy opened this issue Nov 24, 2020 · 1 comment · Fixed by #3956
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@benjaminbellamy
Copy link
Contributor

benjaminbellamy commented Nov 24, 2020

Describe the bug
Uploading SRT files does not work, SRT files are saved as CSV.

CodeIgniter 4 version
dev-develop

Affected module(s)
CodeIgniter\HTTP\Files\UploadedFile

Expected behavior, and steps to reproduce if appropriate
Create a form.
Upload a file name test.srt.
Uploaded file is renamed test.csv instead of test.srt.

Context

  • OS: Ubuntu 20.04
  • Web server nginX
  • PHP version 7.3

Proposed Solution
When a srt file is uploaded, its mime type is recognized as application/octet-stream.
Then CodeIgniter\Files\File->guessExtension() calls Mimes::guessExtensionFromType($this->getMimeType()); to get the file extension.
Since 'srt' only has ['text/srt', 'text/plain'] the first type matching application/octet-stream is returned : CSV.

So in order to make it work, in Config\Mimes.php we would just need to update srt to:
'srt' => ['text/srt', 'text/plain', 'application/octet-stream'],
Et voilà !

@benjaminbellamy benjaminbellamy added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 24, 2020
@lonnieezell
Copy link
Member

Care to submit a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants