I am using some ASP code for uploading Images....I want to resize the images while uploading .... is it possible in ASP ? The code of uploading is as follows....I got it from net...
Server.ScriptTimeout = 500
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCou
nt)
Dim UploadRequest, strTitle, intHeight, intWidth, strAltText, ContentType, intType,intFormat
Dim filename1
set UploadRequest = CreateObject("Scripting.Di
ctionary")
BuildUploadRequest RequestBin
intFormat=UploadRequest.It
em("THEFIL
E1").Item(
"Value")
UpLoadTheFileImage1
Function UpLoadTheFileImage1
contentType = UploadRequest.Item("THEFIL
E1").Item(
"ContentTy
pe")
filepathname = UploadRequest.Item("THEFIL
E1").Item(
"FileName"
)
filename1 = Right(filepathname,Len(fil
epathname)
-InstrRev(
filepathna
me,"\"))
filename1 = "T_" & second(time) * minute(time) & filename1
Title_filename=filename1
value = UploadRequest.Item("THEFIL
E1").Item(
"Value")
Set ScriptObject = Server.CreateObject("Scrip
ting.FileS
ystemObjec
t")
pathEnd = Len(Server.mappath(Request
.ServerVar
iables("PA
TH_INFO"))
)-17
Set filesys = CreateObject("Scripting.Fi
leSystemOb
ject")
fPath="C:\Inetpub\wwwroot\
marlinreal
estate\amo
r\Images\"
bann= fPath & filename1
path=bann
Set MyFile = ScriptObject.CreateTextFil
e(bann)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
UpLoadTheFileImage1=Title_
filename
End Function
Sub BuildUploadRequest(Request
Bin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,g
etByteStri
ng(chr(13)
))
boundary = MidB(RequestBin,PosBeg,Pos
End-PosBeg
)
boundaryPos = InstrB(1,RequestBin,bounda
ry)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(Reques
tBin,bound
ary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Di
ctionary")
'Get an object name
Pos = InstrB(BoundaryPos,Request
Bin,getByt
eString("C
ontent-Dis
position")
)
Pos = InstrB(Pos,RequestBin,getB
yteString(
"name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,g
etByteStri
ng(chr(34)
))
Name = getString(MidB(RequestBin,
PosBeg,Pos
End-PosBeg
))
PosFile = InstrB(BoundaryPos,Request
Bin,getByt
eString("f
ilename=")
)
PosBound = InstrB(PosEnd,RequestBin,b
oundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,g
etByteStri
ng(chr(34)
))
FileName = getString(MidB(RequestBin,
PosBeg,Pos
End-PosBeg
))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,g
etByteStri
ng("Conten
t-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,g
etByteStri
ng(chr(13)
))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,
PosBeg,Pos
End-PosBeg
))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,b
oundary)-2
Value = MidB(RequestBin,PosBeg,Pos
End-PosBeg
)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getB
yteString(
chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,b
oundary)-2
Value = getString(MidB(RequestBin,
PosBeg,Pos
End-PosBeg
))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
uploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(Boundar
yPos+LenB(
boundary),
RequestBin
,boundary)
Loop
End Sub
'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,in
tCount,1))
)
Next
End Function
Or if there is any third party component(not ASPUPload) which can do image resizing..?