- Posts: 21
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Attachments STILL broken? Problems with MP3 files being renamed to TXT
Attachments STILL broken? Problems with MP3 files being renamed to TXT
- Chad Criswell
-
Topic Author
- Offline
- Junior Member
When we attach a PDF file to a K2 article it uploads fine but then it changes the filename from filename.pdf to filename.txt. See the attached image to see what I mean. This worked fine prior to 2.10!
Any idea what is going on? I see there are other posts on here about this same issue...
Also, here is a quick video showing what I am talking about.
drive.google.com/file/d/1_xZBD0uUY_A5vNdBJ9y0z5Bu4xu4ve8D/view
I also tried updating to the 2.10.3 dev release and the problem persists.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
However the issue is 99,999% related to wrong MIME detection in your server. In other words, the server cannot properly detect the file being uploaded is a PDF and as such does not pass on that info (for a valid file upload) to the PHP library that K2 users for file uploads. As such the uploader is renaming the file to a safe .txt extension.
Until the matter is addressed differently to cover cases where MIME detection is not done properly or at least not in a way that is compatible with the upload library K2 uses, you can use the "browser server" option, upload the file through that modal and then select to insert it.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Chad Criswell
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Chad Criswell
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Unless it's some old cPanel version with EA3 and a custom Apache build. More info would be helpful.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Chad Criswell
-
Topic Author
- Offline
- Junior Member
- Posts: 21
What other info would help and I will try to get it?
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Alternatively, try this EA4 profile from Engintron: raw.githubusercontent.com/engintron/engintron/master/cpanel/EasyApache_Profiles/EA4/Engintron_EA4_2019_v1.json
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- James Riley
-
- Offline
- New Member
- Posts: 2
1) after uploading using the attachment screen, I renamed the file (using FTP) from .txt to .mp3 (attachment files are stored in /media/k2/attachments); and
2) editing the corresponding record in the ___k2_attachments mySQL table, changing the file extension on the file name from .txt to .mp3 as well.
I've only attached PDFs to my other articles recently, and have had no issues with the PDFs being renamed. I'm running of a Linux/Apache/cPanel server hosted by A2Hosting.com.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Let me know.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- James Riley
-
- Offline
- New Member
- Posts: 2
Fotis wrote: Try commenting out this line: github.com/getk2/k2/blob/master/administrator/components/com_k2/models/item.php#L439
Let me know.
I've commented out Line 439 [ $handle->file_new_name_body = JFile::stripExt($filename); ]
The file is not only still saved as a txt file, but also renamed with a random file name (see attached screen clipping; you can see the original file name maintained in the download link).
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Adam M
-
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Edit this file github.com/getk2/k2/blob/90cff2f28649fd83a296e9d491ef1f21335dd88b/administrator/components/com_k2/models/item.php#L442-L443 and replace the 2 lines with:
$handle->allowed = array(
"application/arj",
"application/download",
"application/gnutar",
"application/rar",
"application/vnd.rar",
"application/x-bzip",
"application/x-bzip2",
"application/x-compressed",
"application/x-gzip",
"application/x-rar-compressed",
"application/x-unknown",
"application/x-zip-compressed",
"application/x-zip",
"application/zip",
"multipart/x-gzip",
"multipart/x-zip",
"audio/*",
"video/*"
);
Let me know.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Adam M
-
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- Adam M
-
- Offline
- New Member
- Posts: 5
system information
- class version : 0.34dev
- operating system : Linux
- PHP version : 7.3.18
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 8M (8388608 bytes)
- language : en_GB
source is a local file /tmp/phpDsPdnR
- local file OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME type detected as audio/mpeg; charset=binary by UNIX file() command
- MIME validated as audio/mpeg
source variables
- You can use all these before calling process()
file_src_name : phpDsPdnR
file_src_name_body : phpDsPdnR
file_src_name_ext :
file_src_pathname : /tmp/phpDsPdnR
file_src_mime : audio/mpeg
file_src_size : 1956870 (max= 8388608)
file_src_error : 0
process file to /public_html/media/k2/attachments/
- file size OK
- script renamed as phpDsPdnR.txt!
- file mime OK : text/plain
- new file name body : isnt-she-lovely
- destination variables
file_dst_path : /public_html/media/k2/attachments/
file_dst_name_body : isnt-she-lovely
file_dst_name_ext : txt
- no auto_rename if same filename exists
- destination file details
file_dst_name : karlo-isnt-she-lovely.txt
file_dst_pathname : /public_html/media/k2/attachments/isnt-she-lovely.txt
cleanup
- delete temp file /tmp/phpDsPdnR
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
So anyone who had issues before is advised to test this one out.
Thank you.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Adam M
-
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Attachments STILL broken? Problems with MP3 files being renamed to TXT