Modificare il file:
\Admin\Cancella\imager.asp
<!--#include file="include/Prodotti_dbconnection.asp"--> <% Dim oleHeaderSize, binImage Dim lngImageSize, binTemp Dim nSkip Response.Expires = 0 Response.Buffer = True Response.Clear ' connect to the database Set oConnection = Server.CreateObject("ADODB.Connection") oConnection.ConnectionString = strConnection oConnection.ConnectionTimeout = 7 oConnection.Open ' table and where clause needs to be dynamic sSQL = "SELECT " & AddWrappers(Request("picfield")) & " FROM " & AddWrappers(Request("pictable")) & " " & _ "WHERE " & Request("where") Set rsPic = oConnection.Execute(sSQL) binTemp = rsPic(0).GetChunk(300) if IsNull(binTemp) then Call DisplayNoImage response.end end if strImageType = GetImageType(binTemp, nSkip) if strImageType="" then Call DisplayFileImage response.end end if lngImageSize = rsPic(0).ActualSize binImage = rsPic(0).GetChunk(lngImageSize - 300) Response.ContentType = strImageType Response.BinaryWrite MidB(binTemp, nSkip+1, 300-nSkip) Response.BinaryWrite binImage rsPic.Close Set rsPic = Nothing oConnection.Close Set oConnection = Nothing Response.End Function GetImageType(ByteArray, nSkip) dim c1,c2,c3,c4 c1 = Chr(AscB(MidB(ByteArray,1,1))) c2 = Chr(AscB(MidB(ByteArray,2,1))) c3 = Chr(AscB(MidB(ByteArray,3,1))) c7 = Chr(AscB(MidB(ByteArray,7,1))) c8 = Chr(AscB(MidB(ByteArray,8,1))) c9 = Chr(AscB(MidB(ByteArray,9,1))) c10 = Chr(AscB(MidB(ByteArray,10,1))) GetImageType="" nSkip = 0 if c1 = "B" and c2 = "M" then GetImageType = "image/bmp" elseif c1 = "G" and c2 = "I" and c3="F" then GetImageType = "image/gif" elseif (c7 = "J" and c8 = "F" and c9="I" and c10="F") _ or (c7 = "E" and c8 = "x" and c9="i" and c10="f") then GetImageType = "image/jpg" end if if GetImageType="" then for i=1 to lenb(ByteArray)-3 if Chr(AscB(MidB(ByteArray,i,1))) ="B" and Chr(AscB(MidB(ByteArray,i+1,1))) ="M" then GetImageType = "image/bmp" nSkip=i-1 i=lenb(ByteArray) elseif Chr(AscB(MidB(ByteArray,i,1))) ="G" and Chr(AscB(MidB(ByteArray,i+1,1))) ="I" and _ Chr(AscB(MidB(ByteArray,i+2,1))) ="F" and Chr(AscB(MidB(ByteArray,i+3,1))) ="8" then GetImageType = "image/gif" nSkip=i-1 i=lenb(ByteArray) elseif Chr(AscB(MidB(ByteArray,i,1))) ="J" and Chr(AscB(MidB(ByteArray,i+1,1))) ="F" and _ Chr(AscB(MidB(ByteArray,i+2,1))) ="I" and Chr(AscB(MidB(ByteArray,i+3,1))) ="F" then GetImageType = "image/jpeg" nSkip=i-7 i=lenb(ByteArray) end if next end if End Function Sub DisplayNoImage Response.ContentType = "image/gif" Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.GetFile(Server.MapPath("images/no_image.gif")) Set b = a.OpenAsTextStream(1,-1) Response.BinaryWrite(b.Read(999999)) End Sub Sub DisplayFileImage Response.ContentType = "image/gif" Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.GetFile(Server.MapPath("images/file.gif")) Set b = a.OpenAsTextStream(1,-1) Response.BinaryWrite(b.Read(999999)) End Sub function AddWrappers(strName) if (InStr(1, strConnection, "Microsoft Access")>1 or isnumeric(strName) or InStr(strName, " ")>0 or InStr(strName, "'")>0 or InStr(strName, "_")>0 or InStr(strName, "-")>0 or InStr(strName, "#")>0 or InStr(strName, ")")>0 or InStr(strName, "(")>0 or InStr(strName, "/")>0) and Left(strName,1)<>strLeftWrapper then AddWrappers = strLeftWrapper + strName + strRightWrapper else AddWrappers = strName end if end function %>
[
Íàçàä
]