Hello all,
Does anyone know if there is a way to download a .jpg file using the download dialog, and not have the user right click and hit 'save'?
I really hope this can be done.
Thanks SapThe only way I know is to put the .jpg into a ZIP file and link to that. It will then automatically invoke the download dialog box. They will of course have to unzip it once it has been downloaded.Yes you can by suing ADODB.Stream, not just photo also other mime types.
Here is the code used in my photo gallery.
Click the link and you'll see the download dialog box.
<!-- m --><a class="postlink" href="http://www.ex-designz.net/gallery/downloadpic.asp?picname=45.jpg">http://www.ex-designz.net/gallery/downl ... ame=45.jpg</a><!-- m -->
<%
Response.Buffer = True
Dim strFileName
Const adTypeBinary = 1
strFileName = Request.QueryString("picname")
Response.Clear
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile = Server.MapPath("../gallery/images/"& strFileName)
strFileType = lcase(Right(strFileName, 4))
' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".bmp"
ContentType = "image/bmp"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>
Dexter Zafra
<!-- m --><a class="postlink" href="http://www.ex-designz.net">http://www.ex-designz.net</a><!-- m -->
Does anyone know if there is a way to download a .jpg file using the download dialog, and not have the user right click and hit 'save'?
I really hope this can be done.
Thanks SapThe only way I know is to put the .jpg into a ZIP file and link to that. It will then automatically invoke the download dialog box. They will of course have to unzip it once it has been downloaded.Yes you can by suing ADODB.Stream, not just photo also other mime types.
Here is the code used in my photo gallery.
Click the link and you'll see the download dialog box.
<!-- m --><a class="postlink" href="http://www.ex-designz.net/gallery/downloadpic.asp?picname=45.jpg">http://www.ex-designz.net/gallery/downl ... ame=45.jpg</a><!-- m -->
<%
Response.Buffer = True
Dim strFileName
Const adTypeBinary = 1
strFileName = Request.QueryString("picname")
Response.Clear
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile = Server.MapPath("../gallery/images/"& strFileName)
strFileType = lcase(Right(strFileName, 4))
' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".bmp"
ContentType = "image/bmp"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>
Dexter Zafra
<!-- m --><a class="postlink" href="http://www.ex-designz.net">http://www.ex-designz.net</a><!-- m -->