AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Closed] Downloading custom file types from wpForo forum attachment

2 Posts
2 Users
0 Reactions
2,113 Views
Posts: 1
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@luminacommunityengagement)
New Member
Joined: 5 years ago
[#17713]

Hi there! I am setting up a forum for our website, and our users need to be able to upload a custom file type called an Analytica model (.ana).  Since .ana is a custom file type, I installed the WP plugin "File Upload Types" and added .ana files to the list of approved uploads. So the Analytica models (.ana) files can be uploaded to the forum, however when someone viewing the post then clicks on the uploaded model, it opens in a separate browser as a text file. 

My question is: how do I allow a user to download custom file types instead of having it open as a text file in a browser?  I realize this is partly a wpForo question, partly a File Upload Type question, but any help would be much appreciated! Alternatively, if someone could click on the attachment and have it automatically launch our Analytica program, that would be even better! Until our users can upload and download these Analytica models (.ana file types), our forum is somewhat useless!  

Note: In "File Upload Types" plugin, you are supposed to assign a custom MIME type, and using a File Type Checker website, it tells me that the MIME type is plain/html.  However this does not seem correct, because the .ana files are launched in the Analytica software/application.  

Thanks!
KM


1 Reply
Robert
Posts: 10738
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 2 months ago
Posted by: @luminacommunityengagement

Note: In "File Upload Types" plugin, you are supposed to assign a custom MIME type, and using a File Type Checker website, it tells me that the MIME type is plain/html.  However this does not seem correct, because the .ana files are launched in the Analytica software/application.  

I think the problem comes for registering the custom file type. How have you registered it and what MIME type have you set for .ana file format?

 

Posted by: @luminacommunityengagement

My question is: how do I allow a user to download custom file types instead of having it open as a text file in a browser?

Put this hook code in the functions.php file of your current active theme or use Code Snippets plugin for inserting custom hook code:

function wpforo_force_download_ana_files($text){
if( strpos($text, 'wpforo-default-attachment') !== FALSE && strpos($text, '.ana') !== FALSE ){
$text = preg_replace('|(class=\"wpforo-default-attachment\"[^><]+href=\"[^\]\[]+\.ana\")|s', '$1 download ', $text);
}
return $text;
}
add_filter('wpforo_content_after', 'wpforo_force_download_ana_files', 10);

Share: