Keyword

Attachments STILL broken? Problems with MP3 files being renamed to TXT

  • Chad Criswell
  • Chad Criswell's Avatar Topic Author
  • Offline
  • Junior Member
More
5 years 2 months ago - 5 years 2 months ago #174940 by Chad Criswell
This has been occurring for well over a month now back to 2.10's release and is still going on after I updated to 2.10.2 today.

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.
Attachments:
Last edit: 5 years 2 months ago by Chad Criswell.

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #174959 by JoomlaWorks
I believe you :)

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
  • Chad Criswell's Avatar Topic Author
  • Offline
  • Junior Member
More
5 years 2 months ago #174968 by Chad Criswell
Thank you for the reply, but can you help clarify a bit for me? I maintain the server but am not aware of any changes recently that I made that would have fiddled with this beyond routine cpanel and kernel updates. Any idea what path I would take to troubleshoot this MIME type issue?

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #174973 by JoomlaWorks
It depends on your server setup. What's the underlying webserver? Apache, Nginx, IIS?

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
  • Chad Criswell's Avatar Topic Author
  • Offline
  • Junior Member
More
5 years 1 month ago #174979 by Chad Criswell
Apache with cpanel

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #174982 by JoomlaWorks
On a stock (current) cPanel server, there are no MIME setup issues with Apache.

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
  • Chad Criswell's Avatar Topic Author
  • Offline
  • Junior Member
More
5 years 1 month ago - 5 years 1 month ago #174983 by Chad Criswell
It's just a stock cpanel server. No changes were made when setting it up other than installing cpanel and doing yum updates. It does have cpanel kernelcare installed on it but other than that nothing special. Cpanel version is the most recent one. It just updated the other day. Centos 7.7.

What other info would help and I will try to get it?
Last edit: 5 years 1 month ago by Chad Criswell.

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #174985 by JoomlaWorks
Are you using the stock EasyApache4 setup? Or did you reconfigure it from scratch?

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.

More
5 years 3 weeks ago - 5 years 3 weeks ago #175259 by James Riley
I discovered a similar issue today when trying to attach an MP3 to my Item. I manually fixed the problem by:
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.
Last edit: 5 years 3 weeks ago by James Riley. Reason: rewrote a bit for better clarity

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #175260 by JoomlaWorks

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #175264 by James Riley

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).
Attachments:

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago #175265 by JoomlaWorks
Revert the change.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #176086 by Adam M
I've been using K2 for many years but I'm also now having this same issue since updating to the most recent version. My issue is when I upload mp3s which are turned to .txt files. Was there any further solution at all? I've spoken to my hosting company and they've said everything is fine their end. Many thanks.

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #176087 by JoomlaWorks
Try this please.

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.

More
4 years 10 months ago #176089 by Adam M
Thanks Fotis, I made the change but this resulted in the file not uploading at all. The attachment details were still added to the database but without a file name.

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #176091 by Adam M
Here's the log from the upload class in case it's helpful...

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.

More
4 years 10 months ago #176092 by JoomlaWorks
Resolved.

Try v2.10.4 (dev) from: getk2.org/downloads/?f=K2_Development_Release.zip

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.

More
4 years 10 months ago #176093 by JoomlaWorks
The above dev release resolves issues for many other file types as well and contains newer MIME detection for some.

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.

More
4 years 10 months ago #176095 by Adam M
Thanks so much for your efforts, this has solved the issue for me.

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #176097 by JoomlaWorks
Great :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum