ASP
Here you can find some FREE usefull Classic ASP / VBScript code snippets, class modules, etc.
Function BinReadFile(String)String
Read a local binary (non-text) file contents.
Example
Usage BinReadFile (File path) You can specify both absolute or relative file paths. The function returns the file contents using a Binary Stream. <% Dim binaryData binaryData = BinReadFile("docs/manual.pdf") %> Source Code <%
Function BinReadFile(filename) Const adTypeBinary = 1 Dim bs, filepath if mid(filename,2,1)<>":" and left(filename,2)<>"\\" then filepath = Server.MapPath(filename) else filepath=filename On Error Resume Next Set bs = Server.CreateObject("ADODB.Stream") bs.Type = adTypeBinary bs.Open: bs.LoadFromFile filepath BinReadFile = bs.Read bs.Close: set bs=nothing On Error Goto 0 End Function %> |