Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-07-2011, 01:41 PM #1
- Join Date
- Mar 2011
- Thanked 0 Times in 0 Posts
Prompt user for download - Please help!
I have zero experience using ASP and I'm really stuck.
A client wanted an image gallery making with a load of thumbnails and when the visitor clicks on the thumbnail it prompts for a download.
I have made the gallery with all the thumbnails and put the thumbnail inside an <a> when the visitor clicks on the link it directs to download.asp and passes through the image name as a variable called image.
<a href="download.asp?images=file-name.jpg><img src="images/thumbnails/file-name.jpg" alt="" /></a>
So far I have managed to get the script to prompt for a download but the image was empty when i downloaded it so i tried to use Server.MapPath and now it doesn't work at all.
Here is download.asp
'Set variable image and get image name though the url
Response.ContentType = "image/jpeg"
Please could someone point me in the right direction.
Thanks a lot
03-07-2011, 07:45 PM #2
Where did you come up with Response.TransmitFile ????
No such thing.
Also, you can't use ~ in a path with Server.MapPath and ASP. That's an ASP.NET-ONLY convention.
It's been quite some time since I have done this, but it should be *something* like this:
Code:<% ' make sure there are *NO* characters in the file prior to the < of the above line! name = Trim(Request("image")) Set strm = Server.CreateObject("ADODB.Stream") strm.Type = 1 ' binary strm.LoadFromFile( Server.MapPath( "/images/hi/" & name ) ) Response.AddHeader("content-disposition", "attachment;filename="&name) Response.ContentType = "image/jpeg" Response.BinaryWrite strm.Read Response.End ' stuff after here does not matter as response.end means "end now" %>
Be yourself. No one else is as qualified.