corsasport.co.uk
 

Corsa Sport » Message Board » General Chat » HTML/JS Help...


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author HTML/JS Help...
PaulW
Member

Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
7th Jul 04 at 10:24   View User's Profile U2U Member Reply With Quote

I've seen it done on other sites, but I can't remember for the life of me where...

I want to add links to download files from an online resources system (DOC, PDF, XLS, MDB, etc), and instead of it opening in the same window or a new window, I want it so when the user left-clicks, instead of opening it up in IE or whatever, it displays the Save Target box.

Reason for this, right-clicking has been disabled on the site, so can't right-click, save-target as
PaulW
Member

Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
7th Jul 04 at 11:34   View User's Profile U2U Member Reply With Quote

Or if anyone can help me with headers in asp??

code:

Response.AddHeader "Content-Disposition","attachment;filename=" & fileName
Response.AddHeader "Content-Length", stream.Size
Response.CharSet = "UTF-8"
Response.ContentType = "application/x-msdownload"
Response.BinaryWrite stream.Read



I found that as an example, but I aint sure how to implement it. I suppose the best way would be to call a seperate file (ie, when a download link is clicked, instead of linking straight to the file, it will open something like

http://blahblah.com/filedl.asp?download=\lrc\it\p433.doc

than that page runs through the above header to download the file instead of opening it?? & also closes itself, so it opens up as _blank & then closes once headers have been processed??

arrrrgggg I aint ever worked with HTTP headers before, so I'm lost!

[Edited on 07-07-2004 by PaulW]

[Edited on 07-07-2004 by PaulW]
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
7th Jul 04 at 12:55   View Garage View User's Profile U2U Member Reply With Quote

The problem you have is that MIME types are interpretted by the browser, and its up to that to decide what to do with them. What you're doing there is telling it that its basically a foreign ContentType and that data will follow - this is your best of the bad situation as the most the browser can usually do with this is download it somehwere - there will be no app set up to handle it. The problem there of course is that you need to get a filename and file extension in the downloaded file, I'm sure there must be some other hacks somewhere to supply that.

Don't forget - the link is to the file so you shouldn't need to worry about targetting it properly. You don't need a new window as you're about to provide something the browser can't handle anyway, and a Save As box should follow.

Make sure the output from your filedl.asp script is *only* the file (albeit with the spoofed header) and you should be OK.

I'd be looking in other webmail/CMS type apps to see how they do it. Even its its not ASP you should still be able to see how the app is fooling the browser.
Dom
Member

Registered: 13th Sep 03
User status: Offline
7th Jul 04 at 13:09   View User's Profile U2U Member Reply With Quote

paul, the exampl you posted will work fine mate and like you say, just pop it into a seperate ASP file and call it or you could pop it into a function/routine and call it from that

however, i would recommend that you have a butchers and www.pscode.com and look up some more examples, because there are other ways to go about it mate (cant remember though, been a long time since ive done stuff in ASP so)

 
New Topic

New Poll

Corsa Sport » Message Board » General Chat » HTML/JS Help... 22 database queries in 0.0106091 seconds