Solved

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

Posted on 2004-08-12
8
197 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
phpmyadmin installation 3 53
Could you suggest how to deal with  AH00124 Apache error? 10 127
Problem to go to page 12 81
PHP_POST() error message 9 40
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

14 Experts available now in Live!

Get 1:1 Help Now