Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-12
8
Medium Priority
?
208 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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
 
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

971 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