Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Forcing a link to download to the HD instead of loading in-window

Forcing a link to download to the HD instead of loading in-window
Thread Tools
chasnhisimac
Junior Member
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 20, 2002, 06:00 PM
 
Does anyone know what you can do in the HTML or on the server-side (Apache) to make a certain link always download the file instead of trying to interpret/load it in the window.

In specific, I want a link that will force it to download .jpg's and .mov's.

0- end of document;
     
reader50
Administrator
Join Date: Jun 2000
Location: California
Status: Offline
Reply With Quote
Feb 20, 2002, 11:43 PM
 
stuff / archive / encode the files. A .sit, .zip, .tar file will (usually) download when clicked. The browser seems to be in control of the download option, rather than the page code. I could be wrong.
     
chasnhisimac  (op)
Junior Member
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 21, 2002, 12:06 AM
 
Originally posted by reader50:
<STRONG>stuff / archive / encode the files. A .sit, .zip, .tar file will (usually) download when clicked. The browser seems to be in control of the download option, rather than the page code. I could be wrong.</STRONG>
That's not gunna do it. I need this to work for any .mov or .jpg I have, and there are a lot because it loads them from a database.
     
John Nicholas
Fresh-Faced Recruit
Join Date: Jun 2001
Status: Offline
Reply With Quote
Feb 21, 2002, 12:33 AM
 
Originally posted by chasnhisimac:
<STRONG>Does anyone know what you can do in the HTML or on the server-side (Apache) to make a certain link always download the file instead of trying to interpret/load it in the window.

In specific, I want a link that will force it to download .jpg's and .mov's.

0- end of document;</STRONG>
You need to do this on the server side. If you are using PHP for example you might have a line like this

header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=download.mov");

then code that reads the file and writes it out, probably fpassthru()

The 'filename=' part tells the browser what filename to use
     
Raman
Mac Elite
Join Date: Mar 2001
Status: Offline
Reply With Quote
Feb 22, 2002, 07:33 PM
 
I think you can use content-type OR content-disposition, but not both.

Also, you're gonna have fun in IE because regardless of what type of data you tell IE, it sniffs the information to see if it knows what it is - if it does then I'll try to open it up in a helper program if possible, if not then it'll ask the user to download it.

I'm pretty sure IE 4.0sp2 + do this.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:54 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,