Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have uploaded a binary .war file which is nothing but a .zip file with Java web application extension. When I hit the URL for this file, I see junk characters in browsers.

URL: http://www.javaquizmaker.com/QuizGenerator.war

Need a way by which I can make the users download this file.

By the way, I uploaded using FTP and the Add new media feature of WordPress gave me an error about File upload not supported due to security reasons.

Pls. advise.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

If your webserver is Apache, you'll need to tell apache what kind of mime type your file is, so Apache knows how to handle it. You should be able to use the "application/octet-stream" mime type in your .htaccess, in order for Apache to force a download. Learn more here: http://www.htaccess-guide.com/adding-mime-types/ (see the 3rd paragraph, starting with "A Handy Trick").

Regarding the media library -- by default, wordpress blocks most types of files from being uploaded. To allow more file types, you'll need to filter the allowed types. Add this to your theme's functions.php:

<?php
function custom_upload_mimes($mime_types) 
{
    $mime_types['war'] = 'application/octet-stream';
    return $mime_types;
}
add_filter('upload_mimes', 'custom_upload_mimes');
?>
share|improve this answer
    
You are a life saver –  Sandeep Jun 20 '12 at 4:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.