Solved

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

Posted on 2004-08-12
8
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

615 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