You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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à !
The text was updated successfully, but these errors were encountered:
benjaminbellamy
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
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 oftest.srt
.Context
Proposed Solution
When a
srt
file is uploaded, its mime type is recognized asapplication/octet-stream
.Then
CodeIgniter\Files\File->guessExtension()
callsMimes::guessExtensionFromType($this->getMimeType());
to get the file extension.Since
'srt'
only has['text/srt', 'text/plain']
the first type matchingapplication/octet-stream
is returned :CSV
.So in order to make it work, in
Config\Mimes.php
we would just need to updatesrt
to:'srt' => ['text/srt', 'text/plain', 'application/octet-stream'],
Et voilà !
The text was updated successfully, but these errors were encountered: