Link to home
Start Free TrialLog in
Avatar of gsoujanya
gsoujanya

asked on

How to force a download dialog box?

Hi,
I have a problem with downloading the file.
I provide a list of all the files uploaded to a particular item in my web page. All my uploaded files are stored in a directory on the web server. When the user clicks on one of those links, I need to let him download it. It shouldn't display the contents of the uploaded file.

Setting Response.ContentType doesn't seem to work.

How can this be done?

Thanks,
Soujanya

Avatar of jitganguly
jitganguly

Soujanya,
Change the file extension to .zip and try. I mean you will have to make a zip file. MS products on IE will open it IE only. It just treats as an active x control. For example
<% Response.ContentType = "application/vnd.ms-excel" %> on IE will open excel in IE, but in NN it will ask you to downlaod/open.
You can also try input type=file with some other extensions
Avatar of gsoujanya

ASKER

oops i am sorry...
If the file to be downloaded is a recognised MIME type, it will launch the file. If it is not recognised, then if will prompt user for download. To force download, you got to change it to zip format.

No tricks.

hongjun
How do I change it to Zip format?
Download WinZip at http://www.winzip.com
It's a software that can convert it to a zip format. A zip format is a compressed version of a file. You can then unzip it back to the original state using the same software.

hongjun
Zip those files with winzip. If you do not have it get it from www.winzip.com
Zip those files with winzip. If you do not have it get it from www.winzip.com
Have a look at the aspSmartupload component from http://www.aspsmart.com/. This is seems to be good one
Hey, I know how to zip a file using Winzip. I want to know how to zip it programatically and display it to the user so that when he clicks on the link, the download box appears.
   
You do not programatically zip/unzip. That would be a pain. Manually do that. Or change teh file extension. Whenever it can not find the mime type, it will ask you to download
Can you use COM?
I can send you COM that can do zipping programatically.
Post your e-mail, I will send you COM
Thanks!
my email is soujanya.rani@indsys.ge.com
Why not zip all files first? It would be a waste of resources to go through the zipping process when user tries to download something. Imagine what if user is trying to download something that is large.

hongjun
I don't want to zip all the files in the begining itself. If there r 3 files which are uploaded and the user needs to modify just one of them, why should he be made to download all 3 of them.

I'm going to have to check this out when I get back to work on Tuesday, but it seems to me that I read a technique just recently for doing this.

It MIGHT have been to use the ContentType header and trick the browser into thinking that the file was either a ZIP file or an executable.

If memory serves correctly, those two types effectively force a save as dialog box.  I don't think that the actual content being downloaded needs to be either of those types.  It's just that the browser needs to THINK it is.

I'll keep an eye on this question to see what it's status is next week.

Tom
ASKER CERTIFIED SOLUTION
Avatar of CJCraft
CJCraft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Hello,

This question has been open for quite a while now and needs to be wrapped up.

EXPERTS: If any of the experts could come back and post any suggestions as to how they feel this could be wrapped up (delete, 0 PAQ, award points, etc), I'm sure the moderators would appreciate it.  If you feel you deserve points here, but don't care to respond, the question might very well get DELETED.  

ASKER:  Please return and finalize this question.  Abandoning a question is in violation of the member agreement.

Please do NOT accept this comment as an answer, as I am simply trying to alert those involved that the question is still open.

Thank you,

BRUNO
This question appears to have been abandoned. Please come back to this question and do the necessary evaluation or feedback. I will invite a Moderator to close this question if there's no reply from you after seven days.

I suggest
<points to CJCraft>

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **

hongjun
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange