Amita
asked on
resizing of image while uploading ?
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..?
Server.ScriptTimeout = 500
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCou
Dim UploadRequest, strTitle, intHeight, intWidth, strAltText, ContentType, intType,intFormat
Dim filename1
set UploadRequest = CreateObject("Scripting.Di
BuildUploadRequest RequestBin
intFormat=UploadRequest.It
UpLoadTheFileImage1
Function UpLoadTheFileImage1
contentType = UploadRequest.Item("THEFIL
filepathname = UploadRequest.Item("THEFIL
filename1 = Right(filepathname,Len(fil
filename1 = "T_" & second(time) * minute(time) & filename1
Title_filename=filename1
value = UploadRequest.Item("THEFIL
Set ScriptObject = Server.CreateObject("Scrip
pathEnd = Len(Server.mappath(Request
Set filesys = CreateObject("Scripting.Fi
fPath="C:\Inetpub\wwwroot\
bann= fPath & filename1
path=bann
Set MyFile = ScriptObject.CreateTextFil
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
UpLoadTheFileImage1=Title_
End Function
Sub BuildUploadRequest(Request
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,g
boundary = MidB(RequestBin,PosBeg,Pos
boundaryPos = InstrB(1,RequestBin,bounda
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(Reques
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Di
'Get an object name
Pos = InstrB(BoundaryPos,Request
Pos = InstrB(Pos,RequestBin,getB
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,g
Name = getString(MidB(RequestBin,
PosFile = InstrB(BoundaryPos,Request
PosBound = InstrB(PosEnd,RequestBin,b
'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
FileName = getString(MidB(RequestBin,
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,g
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,g
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,b
Value = MidB(RequestBin,PosBeg,Pos
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getB
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,b
Value = getString(MidB(RequestBin,
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
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
Next
End Function
Or if there is any third party component(not ASPUPload) which can do image resizing..?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Excellent list ap_sajith! and bookmarked :o)
Hi Gary,
Could you look at this question?
https://www.experts-exchange.com/questions/20714670/Web-Server-Authentication.html
Cheers!!
Could you look at this question?
https://www.experts-exchange.com/questions/20714670/Web-Server-Authentication.html
Cheers!!
Hi Amita,
Any updates?
Cheers!!
Any updates?
Cheers!!
http://www.aspjpeg.com/download.html