Solved

Making ALL files in a directory available for download through a "save-as" dialog box

Posted on 2004-08-12
8
196 Views
Last Modified: 2010-03-04
I have a number of files in my "/files" directory that I would like to make available for download, through links on my site.

Some are ZIP files, some are word documents, some are images and some are HTML documents.

As it is right now, if someone clicks on a link to a ZIP file, a dialog box asks them if they wish to save the file to disk.  But if they click on an image or an HTML document, it opens it up in the browser.   I want this dialog box for ALL files in the /files directory, not just for applications.

Can I do this by controlling headers with .htaccess?  If so, how?

Thanks!
0
Comment
Question by:hankknight
  • 4
  • 3
8 Comments
 
LVL 15

Expert Comment

by:periwinkle
ID: 11784911
As I understand it, what happens when a user gets a download file will depend upon how their computer itself if configured, not on how you configure things on the server.  Basically, depending upon the doc type, the user's computer will handle using the handler that they have registered.
0
 
LVL 2

Expert Comment

by:rmharwood
ID: 11784969
You can do it this way (I think):

Place the entry

    ForceType application/octet-stream

in the .htaccess file in your /files directory.
0
 
LVL 16

Author Comment

by:hankknight
ID: 11786400
Thanks, rmharwood.

You have the right idea, this is what I want to do.

I created a file called ".htaccess" and placed it in the directory but files are still being shown through the browser instead of being downloaded.
0
 
LVL 2

Expert Comment

by:rmharwood
ID: 11786703
Ok... your server configuration must allow you to override the "FileInfo" options using .htaccess files. Are you the admin of the server? If not you will need to ask if you can do this. They'll need to add

    AllowOverride FileInfo

into their Apache config in the approproate place.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 16

Author Comment

by:hankknight
ID: 11787296
Yes, I have root access.

What are the security implications of me making the change you suggested?
0
 
LVL 2

Accepted Solution

by:
rmharwood earned 500 total points
ID: 11787336
I don't think there are any. Just do something like this:

    <Location /files>
        AllowOverride FileInfo
    </Location>

which just allows .htaccess files in and under /files to override the global file type settings.

The above needs to go in your virtual host section or your global config if you're not using virtual hosts.
0
 
LVL 16

Author Comment

by:hankknight
ID: 11787436
What is the name of the global config file?
0
 
LVL 2

Expert Comment

by:rmharwood
ID: 11787463
>  What is the name of the global config file?

httpd.conf
(usually)

I guess you've not edited this before? If you've got access to the config file anyway you could put

    ForceType application/octet-stream

in the global config file in place of "AllowOverride..." and then you don't even need a .htaccess file.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now