![]() |
|
#1
|
||||
|
||||
Force a file downloadSorry for all the simple questions, but I am pretty new to this.
Is there a way to force a file download? I have been putting files for download on my site with the following: HTML Code:
This works, but when you left click on it, it will show you the graphic. Obviously, you can right click and download it and I have seen other pages where this is necessary, but I am thinking there has got to be a way to force a download when the link is clicked. |
||||
|
#2
|
||||
|
||||
|
I think it has to do with the Content-Type headers for files in that particular folder. If you can change that to be not auto set at "image/gif", then you will force a download. I am just guessing, it may be not as simple as that but surely it's something for you to look into..
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
Yup, J was there I think. You've to somehow tell IE not to be cleaver, and simply download the file, not view it itself. I think this can be done by adding this header (but keeping the content-type intact):
Code:
There is PHP code on forums.devshed.com which would do you perfectly. But I can't find anything to do with changing Apache's settings for a single directory. GF |
|
#4
|
||||
|
||||
|
Thanks to both of you, J and Garth.
That is exactly what I needed. Unfortunately, I am a glutton for punishment and I am doing this entire thing in C, so I had to write my own routine to place the header. I think it works. I have a test site that I placed under the Web site review forum. For those interested, here is a poorly written C file that will handle this. You just need to pass the file location as the first parameter. CPP / C++ / C Code:
One thing that I have learned in all of this is that it is crucial to have a newline after the header definition. So the \n\n at the end of the printf statements are necessary. |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| Re: Programming Techniques | WaltP | C Programming Language | 0 | 10-Mar-2004 00:56 |
| How to allow download file in Apache Web server? | Zaro | Apache Web Server Forum | 1 | 24-Feb-2004 03:41 |
| read specified range of lines from file | etron | C Programming Language | 8 | 18-Feb-2004 09:04 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The