Forums
This topic is locked
Download file stored in access db?
Posted 15 Dec 2002 09:31:47
1
has voted
15 Dec 2002 09:31:47 Kobus Rossouw posted:
I have files stored in access db (BLOB) . I want users to be able to view and download the stored files. I have looked all over for tutorials/extensions but can't find any.
Any help would be greatly appreciated.
Thanks
Dreams
Replies
Replied 17 Dec 2002 06:47:23
17 Dec 2002 06:47:23 Alan Strahsburg replied:
Here's what I do, it's actually a fairly simple process.
Response.Buffer = True ' because we need to clear
Response.Clear ' gets rid of anything we or the server already wrote
Response.AddHeader "Content-Disposition", "inline; filename=" & FileName
Response.ContentType = getMimeType(fileext) ' you may already know the mimetype, if so, there's no need for the function, just put the mimetype here instead
Response.BinaryWrite(BlobString)
'function for determining filetype
Function getMimeType(ext)
SELECT CASE ext
CASE "doc" mimetype = "Application/msword"
CASE "xls" mimetype = "Application/msexcel"
CASE "ppt" mimetype = "Application/powerpoint"
CASE "pot" mimetype = "Application/powerpoint"
CASE "txt" mimetype = "Text/plain"
CASE "rtf" mimetype = "Application/rtf"
CASE "jpg" mimetype = "Image/jpeg"
CASE "jpeg" mimetype = "Image/jpeg"
CASE "bmp" mimetype = "Image/bitmap"
CASE "gif" mimetype = "Image/gif"
CASE "tif" mimetype = "Image/tiff"
CASE "pic" mimetype = "Image/x-pict"
CASE "psd" mimetype = "Application/x-photoshop"
CASE "ppd" mimetype = "Application/x-photoshop"
CASE "htm" mimetype = "Text/html"
CASE "html" mimetype = "Text/html"
CASE "pdf" mimetype = "Application/pdf"
CASE "mov" mimetype = "Video/quicktime"
CASE "mpg" mimetype = "Video/mpeg"
CASE "aif" mimetype = "Audio/aiff"
CASE "au" mimetype = "Audio/basic"
CASE "voc" mimetype = "Audio/voice"
CASE "wav" mimetype = "Audio/wave"
CASE "zip" mimetype = "Application/x-compressed"
CASE "ps" mimetype = "Application/postscript"
END SELECT
getMimeType = mimetype
END FUNCTION
Response.Buffer = True ' because we need to clear
Response.Clear ' gets rid of anything we or the server already wrote
Response.AddHeader "Content-Disposition", "inline; filename=" & FileName
Response.ContentType = getMimeType(fileext) ' you may already know the mimetype, if so, there's no need for the function, just put the mimetype here instead
Response.BinaryWrite(BlobString)
'function for determining filetype
Function getMimeType(ext)
SELECT CASE ext
CASE "doc" mimetype = "Application/msword"
CASE "xls" mimetype = "Application/msexcel"
CASE "ppt" mimetype = "Application/powerpoint"
CASE "pot" mimetype = "Application/powerpoint"
CASE "txt" mimetype = "Text/plain"
CASE "rtf" mimetype = "Application/rtf"
CASE "jpg" mimetype = "Image/jpeg"
CASE "jpeg" mimetype = "Image/jpeg"
CASE "bmp" mimetype = "Image/bitmap"
CASE "gif" mimetype = "Image/gif"
CASE "tif" mimetype = "Image/tiff"
CASE "pic" mimetype = "Image/x-pict"
CASE "psd" mimetype = "Application/x-photoshop"
CASE "ppd" mimetype = "Application/x-photoshop"
CASE "htm" mimetype = "Text/html"
CASE "html" mimetype = "Text/html"
CASE "pdf" mimetype = "Application/pdf"
CASE "mov" mimetype = "Video/quicktime"
CASE "mpg" mimetype = "Video/mpeg"
CASE "aif" mimetype = "Audio/aiff"
CASE "au" mimetype = "Audio/basic"
CASE "voc" mimetype = "Audio/voice"
CASE "wav" mimetype = "Audio/wave"
CASE "zip" mimetype = "Application/x-compressed"
CASE "ps" mimetype = "Application/postscript"
END SELECT
getMimeType = mimetype
END FUNCTION