Downloading files

Permalink Browser Info Environment
I need to upload and download a specific file type, but the add-on tries to open my file in the web browser rather than prompting the user to download the actual file. The problem is the browser converts the file into a notepad file and is then unuasable. Is there a function where it will simply prompt the user for download rather than try to open the file?

Type: Pre-Sale
Status: Resolved
OFOA
View Replies:
mesuva replied on at Permalink Reply
mesuva
Hi there,

although I believe there is a way to generate links that force the download of files, this is something I think better handled and controlled at the server level.

I believe you can add something like the following to your .htaccess file:
AddType application/octet-stream .xyz

(where xyz is your file extension, you didn't mention what kind of file type you are talking about)

There are other ways you can handle this in a .htaccess file, but this appears to be the simplest method.
OFOA replied on at Permalink Reply
OFOA
That worked perfect!!! Thank you!!!
mesuva replied on at Permalink Reply
mesuva
Great to hear!
OFOA replied on at Permalink Reply
OFOA
I hate microsoft! So apparently the fix you gave me works perfect for chrome and firefox but not internet explorer. Do you know of another line could add that would work for i.e?
mesuva replied on at Permalink Reply
mesuva
I could depend a bit on what version of Internet Explorer.

You could try something like this in your htaccess:

<FilesMatch "\.(?i:xyx)$">
Header set Content-Disposition attachment
</FilesMatch>

(where xyz is the file extension)

I simply googled for this, you might have better luck.
OFOA replied on at Permalink Reply
OFOA
Perfect. I found something similar, kind of a combo of the two, and it works on all browsers now.
<FilesMatch "\.(?i:xyz)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>


Thanks for all your help!

concrete5 Environment Information

# concrete5 Version
5.6.3.1

# concrete5 Packages
Automatic Email Obfuscator (1.2.3), Defensio (1.0), Discussion (1.8.6), Easy tabs (1.7.2), Fancy Image Links (1.3.8), Flowplayer Free (1.2.1), Google Docs Viewer (1.0), GroupDocs Viewer (1.3.7), Iframe (1.0), Innovation (2.2), List files from set (1.0.4), Login (1.1.1), Mega Menu (1.5.30), Paypal Donations Box (1.0.1), Popup Pro (1.6.8), Power Slider Lite (1.1.1), reCAPTCHA (0.9.2), Rigid Light - Theme (2.0), Simple Image Gallery (1.1.3), Social Icons (1.2), Social Share Privacy (1.2.2), Studio Testimonials (1.5.1), Thumbview Template (1.1.1), tnSpacer (1.3).

# concrete5 Overrides
None

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - On - If blocks on the particular page allow it.
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache

# Server API
cgi-fcgi

# PHP Version
5.2.17

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, ctype, curl, date, dba, dbase, dom, exif, filter, ftp, gd, gettext, gmp, hash, iconv, imap, json, ldap, libxml, mbstring, mcrypt, mhash, mime_magic, mysql, mysqli, ncurses, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, posix, pspell, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, SQLite, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Optimizer, zip, zlib.

# PHP Settings
max_execution_time - 120
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 10M
safe_mode - Off
safe_mode_exec_dir - <i>no value</i>
safe_mode_gid - Off
safe_mode_include_dir - <i>no value</i>
sql.safe_mode - Off
upload_max_filesize - 10M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 200000
pcre.recursion_limit - 200000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
safe_mode_allowed_env_vars - PHP_
safe_mode_protected_env_vars - LD_LIBRARY_PATH

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.