Downloading a file without opening it

liunx

Guest
Dear Wizkids,

Need your help once again. I would like to get a 'Open Save ...' dialog box when the user clicks the link on my page that points to a file of known MIME type (such as .doc, .xls or .pdf etc.). I do not want the relevant application(such as Word, Excel, PPT etc.) to be opened to show the document. I dont want to keep the file without an extension on the server.

Can you please help me on this.

Thanks
AmilieOkay you can pass some headers in php. For example.

download-pdf.php
<?
header("Content-Type: application/pdf; name=agreement.pdf");
header("Content-disposition: attachment; filename=agreement.pdf");
?>

If you save a php file with those headers it will download the file that is in the filename. You can link directly to it and the open/save dialogue box will appear.I am not using a php, unfortunately. It is a htm.

Thanks for your response.
Am :-)Then you can't do what you want in html or javascript sorry.Hi Aero,


I'm sorry to resurrect this thread, but I have to ask here (as I'm facing the same dilema myself) - can the <embed> tag be manipulated to meet this end? I understand that with it you can set the mime type, thus providing an un-mimed link...

I'd be greatful if you could expand on this for me.


Paul.What type of file are you trying to get to download?a <embed> tag will not force the file to be downloaded.True. I say just put the file in a .zip file if you don't have any way to use a server side language.Ah, ok.

Well, basically, I have 105 templates for Word (*.dot) which are divided into separate folders on the server. This is a threefold problem, I suppose, as I'm trying to force a download of the type *.dot. I don't know if you've tried this yourselves, but if you attempt to download a .dot file with IE in Windows (the only available platform is IE, and the only available OS is Windows), the file will be saved as a DOCument file! The second part of the problem is the fact that the file must be right-clicked and saved as - it would be a lot easier to tell the user simply to click the required link to download the file... Which brings me onto the final problem - the users themselves! I work in a hospital in the UK with a staff of around 9,000+. This means that there are varying levels of technological understanding - the process has to be as simple as possible to understand, therefore, saving everything to a zip file is, unfortunately, not an option. The associated page explaining the reason and use behind the templates is around 4 or 5 sides of A4, so we don't want to overtax the minds of the users...
True. I say just put the file in a .zip file if you don't have any way to use a server side language.
I notice you mentioned serverside language there. Can this be done with ASP, ASP.NET or VS.NET? (I'm afraid my understanding of web technology is rather poor!)


Paul.mandelbrot, yes, asp should have somethgin similar. might want to post in the asp forum and see if they can help. but if you can send it to IE as a download it will help solve your 3 problems. but the othe rone you face is to where they save it at. every computer will be different if you have a specific place for it to be.

the fact that you have it saving a .DOT file as a document is another problem with the machine. a .DOT file should be a template file as far as Microsoft Word is concerned, unless it is not installed.Would an installable ActiveX plug-in that allowed users to view Word documents via their IE browser be a possibility?why, that is what he is trying to avoid, as far as I understandNot to interject...but why couldn't you just use the asp equivilant to php's header function?


Response.ContentType = "dontknow/thecontenttypeofadotfile"
Response.AddHeader "Content-Disposition", "attachment; filename=filename"

for example?

note: I don't develop in asp, I have more or less no experience with it...but this would seem like a valid method of doing so.why, that is what he is trying to avoid, as far as I understand

Must've missed that in the post but if "the only available platform is IE, and the only available OS is Windows" then I don't see why you wouldn't want to :\

Seems like the easiest solution given that there's prolly hundreds of ActiveX "Open Word Doc in Browser" apps out thereHi All,


The reason behind downloading is purely the application of the templates. These templates are for use by the members of the organisation I work for. Opening the template in IE is not acceptable, as this is not Word - the users need to modify and save their documents and have the full facility of Word to do this. I'm trying to make things as simple as possible for them - remember most of them (probably about 90%, as this is a hospital) are not technically minded.

I would also say - try opening a Word document template from the internet/intranet - I have a standard XP Pro/Office 2002 build, and get DOTs being saved as DOCs, and DOTs being opened as DOCs. This has also happened on a number of other machines that I've tried it on. If this is the case, then chances are it will happen everywhere in the Trust.

As for the location that the users save their files, I've had to explain in the usage document that accompanies these files exactly where to save them (i.e. the path in Word > Tools > Options > Locations > User Templates).

William, many thanks for that - it looks promising. Am I able specify any MIME type within the ContentType property, or do I need to specify one that primes IE for a type of download? I'm asking this, as yours looks like it maaayy be made up!!


Paul.Okay.....are all your users in the same building or at least on the same network?It is made up but the code will prompt IE to download it anyways. Just find the proper mime-type for a microsoft word template .dot file.Hi All,
William, many thanks for that - it looks promising. Am I able specify any MIME type within the ContentType property, or do I need to specify one that primes IE for a type of download? I'm asking this, as yours looks like it maaayy be made up!!


Paul.
yes, you will need the correct mime-type fort he Template, not a document. not even sure if there is a difference.It was late when I posted that -- I don't know the mime type for word docs/word templates...I was kinda hoping that'd make it obvious it had to be changed. I apologise for not mensioning it.

I just looked up a reference for ASP to find the functions I wanted to suggest.

I think it just surprized me that nobody else mensioned it -- I didn't know if thats because you didn't want to do it that way or what.so far I have only seen one,

application/msword

that covers all the word documents I believe. don't see one for a templateLOL! Thanks guys - this is all appreciated.

The reason behind my asing about the MIME type is simply that by specifying some complete gibberish for the type it ensures that Windows doesn't know what to do with it, therefore it would be more likely to provide a download box (if you follow my logic!).

Anyway, we are all on the same LAN, putts.

Thanks for all your help, everyone - I'm going to check a little deeper into this, as I think the just specifying the application/word type may just cause problems - I may even adopt DP's MIME type!! ;)


Paul.it shouldn't matter what mime-type it is, that should almost always give you a download box. even if you specifiy the correct mime.Anyway, we are all on the same LAN, putts.

Paul.

Okay....then you just need to place the templates on some shared network drive and point the Templates setting in Word > Tools > Options to that folder and you shouldn't have to have the ppl d/l new versions because you should be able to just update the template on that one network share and be done with it.LOL! If only it was that simple! Half of the Trust have been common desk-topped, some of the Trust have shared template folders, others in the Trust have specialised group template locations (i.e. dealing with specific specialties), therefore setting this up would be even more of a nightmare than simply giving them an icon to click on a webpage is much the simplest option (i.e. having them download the files into their own folder sets). We've already looked at the most logical options for this...
 
Back
Top