%
' the ConvertBin function and use of the objStream started
' from this article on 4 Guys From Rolla:
' http://www.4guysfromrolla.com/webtech/tips/t041701-1.shtml
Function ConvertBin(Binary)
'This function converts a binary byte into an ASCII byte.
for i = 1 to LenB(Binary)
strChar = chr(AscB(MidB(Binary,i,1)))
ConvertBin = ConvertBin & strChar
Next
End Function
Function ReturnBin(Binary)
'This function converts a binary byte into an ASCII byte.
for i = 1 to LenB(Binary)
strChar = AscB(MidB(Binary,i,1))
ReturnBin = ReturnBin & strChar
Next
End Function
dim objStream
dim strTag, strFilepath, i, strChar
dim isFlash
isFlash = false
strFilepath = astfilename
'Create the Stream object
set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
'Open the stream
objStream.Open
objStream.LoadFromFile strFilepath
'Start from the beginning of the file
objStream.Position = 0
'Read the first three characters of the file
strTag = ConvertBin(objStream.Read(3))
if ucase(strTag) = "FWS" then isFlash=true
' read the next (fourth) position to get the version number
' return it as a Byte and not as a converted character
dim intVersion
intVersion = ReturnBin(objStream.Read(1))
' time to get the height and width
dim curval, readbyte
dim xmax, xmin, ymax, ymin, swfheight, swfwidth
' jump to the 9th position (don't forget that 0 is a position, too!)
objStream.Position = 8
' jump into the JScript with GetRect() that will get the four coordinates
GetRect()
' SWF files calculate width and height in TWIPS (1/20th of a point)
' Therefore, we divide by 20 to get the number of pixels
swfwidth = (xmax - xmin) / 20
swfheight = (ymax - ymin) / 20
'Display the results
'response.write("Filename: " & strFilepath & "
" & vbCrLF)
'response.write("Is it a flash file: " & isFlash & "
" & vbCrLF)
'response.write("Flash version: " & intVersion & "
" & vbCrLF)
'response.write("Width: " & swfwidth & "
" & vbCrLF)
'response.write("Height: " & swfheight & "
" & vbCrLF)
objStream.Close
Set objStream = Nothing 'Clean up...
%>