Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
207 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

660 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