News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

attachment plain text

Started by TheBom, February 10, 2024, 12:01:38 PM

Previous topic - Next topic

TheBom

Quote from: Sesquipedalian on February 13, 2024, 12:07:29 PMThat's odd. Nothing in the showAttachment() function tries to populate an empty MIME type. It just uses whatever is retrieved from the database.

Your right, i have discovered that everything before the  2.1.4 upgrade, so all attachments i had in 2.0.14 and before, all tables are empty with the mime type, but the one's uploaded after the upgrade now include the mime type..
I have run a SQL command to fix this.

Many thanks also for believing in my issue!

TheBom

#21
Okay well there is something strange happening since we did this fix.
Its now downloading as filename.gpx.xml only on the mobile phone, on a regular PC its just downloading as filename.gpx

its making a brand new extension to a existing one  ???


as a quick work around:
When i change the SQL mime_type from text/xml to text/gpx everything is okay..
But 1) don't known if this mime type exists, looks like it isn't 2) it works but default upload always is text/xml so i need to do regular manual change to the sql

Sesquipedalian

1. The correct MIME type for your files is application/gpx+xml, not text/gpx.

2. For a permanent fix for new file attachments, my previous statement still applies:

Quote from: Sesquipedalian on February 11, 2024, 03:06:31 PMHowever, this won't help with new GPX file attachments that your members upload. Until your MIME type detection library is updated, PHP will continue to fail to detect the correct MIME type for those new files. SMF can't do anything about that, because SMF depends on PHP for this task, and PHP depends on the server's operating system.

In order to update the server's MIME type detection library, you will need to talk to your hosting provider.

If your hosting provider is unable or unwilling to update the server's MIME type detection library, you could try creating a modification for SMF that would intervene during the attachment upload process in order to detect these GPX files and set the correct MIME type. However, using an SMF modification for this job will probably not be as reliable as using an up-to-date MIME type detection library, so you should definitely try to get your hosting provider to update that library first.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

TheBom

Quote from: Sesquipedalian on March 31, 2024, 11:58:31 AM1. The correct MIME type for your files is application/gpx+xml, not text/gpx.

2. For a permanent fix for new file attachments, my previous statement still applies:

Quote from: Sesquipedalian on February 11, 2024, 03:06:31 PMHowever, this won't help with new GPX file attachments that your members upload. Until your MIME type detection library is updated, PHP will continue to fail to detect the correct MIME type for those new files. SMF can't do anything about that, because SMF depends on PHP for this task, and PHP depends on the server's operating system.

In order to update the server's MIME type detection library, you will need to talk to your hosting provider.

If your hosting provider is unable or unwilling to update the server's MIME type detection library, you could try creating a modification for SMF that would intervene during the attachment upload process in order to detect these GPX files and set the correct MIME type. However, using an SMF modification for this job will probably not be as reliable as using an up-to-date MIME type detection library, so you should definitely try to get your hosting provider to update that library first.


Yes and so no...
First, thank you for your reply but there is still some investigation going on..


1, true

2, that's not the solution, i have tried the following script on 3 webhosting servers (one is my own and 2 public like Strato and OVHcloud)
They always give me the same output:
text/xml
My own hosting (i own the server myself) is 100% up to date on all fronts but the cross check on 2 other public hosting providers do tell me the same.

<?php
$filename 
"test.gpx";
echo 
mime_content_type($filename);
?>

Also, on the PC everything is OK with the mime type text/xml, it downloads from SMF with test.gpx, the same upload/post on the phone gives me a test.gpx.xml

Maybe i am missing something here but since the pc and phone with the same upload/post gives me 2 different outcomes there is still something going different in the SMF code..

Advertisement: