Ryders512
Guppy
I am using aspjpeg to create thumbnails and reduce original image size. I have a script that can upload up to 5 images at a time. Another script handles the form and uses the aspjpeg component to alter the images then updates a database with the paths, size, length, width, etc. I get an error depending on how many images I uploaded. If I upload all 5 images everything goes through smoothly, however if I upload less than 5 files I can get a different error everytime. Examples of the error can be unable to open file and this is because the component would save a 0 byte file and something about Open Binary. Don't have exact examples of errors but I am using jpg and gif files only. Here is the code for the form and the code for the processing page. Can anyone help me?
Code page
<%Option Explicit%>
<%On Error Resume Next%>
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim intCount
Dim hits
hits = 0
intCount=0
Dim strSQL
Dim fs
Dim strTemp
Dim strName
Dim jpeg
Dim SavePath
Dim L
Dim thumbName
Dim originalSavePath
Dim originalW
Dim originalH
Dim adjustW
Dim adjustH
Dim thumbSavePath
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
mySmartUpload.AllowedFilesList = "jpg,jpeg,gif,png,bmp,tiff"
mySmartUpload.DeniedFilesList = "exe,bat,asp,com,zip,doc"
mySmartUpload.DenyPhysicalPath = True
Set jpeg = Server.CreateObject("Persits.Jpeg")
Set fs = CreateObject("Scripting.FileSystemObject")
thumbSavePath = "/images/thumbnails/"
originalSavePath = "/images/events/"
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Save the files with his original names in a virtual path of the web server
' **************************************************************************
strTemp = fs.GetBaseName(fs.GetTempName)
strTemp = Right(strTemp, Len(strTemp) - 3)
strName = File.FileName
strName = strTemp + strName
End If
SavePath = originalSavePath & strName
file.SaveAS(SavePath)
' sample with a physical path
' file.SaveAs("c:\temp\" & file.FileName)
If Err Then
Response.Write("<strong>Unsuccessful upload: </strong>" & Err.Description & " " & CStr(Err.Number)& " " & Err.Source & "")
Response.Write("<strong>Click the back button to try again.</strong>")
Response.End
Else
jpeg.Open Server.MapPath(SavePath)
originalW = jpeg.OriginalWidth
originalH = jpeg.OriginalHeight
L = 100
If jpeg.OriginalWidth > jpeg.OriginalHeight Then
jpeg.Width = L
jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
jpeg.Height = L
jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If
jpeg.Sharpen 1, 250
'Draw frame: black, 2-pixel width
jpeg.Canvas.Pen.Color = &H000000
jpeg.Canvas.Pen.Width = 2
jpeg.Canvas.Brush.Solid = False
jpeg.Canvas.Bar 1, 1, jpeg.Width, jpeg.Height
adjustW = jpeg.Width
adjustH = jpeg.Height
If UCase(Right(strName, 3)) <> "JPG" Then
strName = strName & ".jpg"
End If
thumbName = "thumb" + strName
SavePath = thumbSavePath & thumbName
jpeg.Save Server.MapPath(SavePath)
jpeg.Close
SavePath = originalSavePath & strName
jpeg.Open Server.MapPath(SavePath)
L = 500
If jpeg.OriginalWidth > jpeg.OriginalHeight Then
jpeg.Width = L
jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
jpeg.Height = L
jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If
jpeg.Sharpen 1, 250
'Draw Text
jpeg.Canvas.Font.Color = &HFF0000
jpeg.Canvas.Font.Family = "Courier New"
jpeg.Canvas.Font.Bold = True
'jpeg.Canvas.Font.Quality = 4
'jpeg.Canvas.Font.BKMode = "Opaque"
jpeg.Canvas.Font.Size = 25
jpeg.Canvas.Print 10, 10, "512ryders.com"
'Draw frame: black, 2-pixel width
jpeg.Canvas.Pen.Color = &H000000
jpeg.Canvas.Pen.Width = 2
jpeg.Canvas.Brush.Solid = False
jpeg.Canvas.Bar 1, 1, jpeg.Width, jpeg.Height
SavePath = originalSavePath & strName
jpeg.Save Server.MapPath(SavePath)
jpeg.Close
strSQL = "INSERT INTO tbl_Images (imageFileName, imageFilePath, imageFileSize, imageHits, imageWidth, imageHeight, thumbFileName, thumbFilePath, thumbWidth, thumbHeight) VALUES ('" & strName & "','"&originalSavePath&"','" & File.Size & "','" & hits & "','" & originalW & "','" & originalH & "','"& thumbName & "','"&thumbSavePath&"','" & adjustW & "','" & adjustH & "');"
adoCon.Execute(strSQL)
Response.Write(file.Name & ", ")
Response.Write("Size = " & file.Size & "bytes, ")
Response.Write(strName & ", ")
Response.Write(file.ContentType & "")
'Response.Write("<table><tr><td><img src='../images/thumbnails/"&thumbName&"' /></td>")
'Response.Write("<td><img src='../images/events/"&strName&"' /></td></tr></table>")
intCount = intCount + 1
End If
Next
Set fs = Nothing
Set jpeg = Nothing
%>
________
marijuana vaporizer
Code page
<%Option Explicit%>
<%On Error Resume Next%>
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim intCount
Dim hits
hits = 0
intCount=0
Dim strSQL
Dim fs
Dim strTemp
Dim strName
Dim jpeg
Dim SavePath
Dim L
Dim thumbName
Dim originalSavePath
Dim originalW
Dim originalH
Dim adjustW
Dim adjustH
Dim thumbSavePath
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
mySmartUpload.AllowedFilesList = "jpg,jpeg,gif,png,bmp,tiff"
mySmartUpload.DeniedFilesList = "exe,bat,asp,com,zip,doc"
mySmartUpload.DenyPhysicalPath = True
Set jpeg = Server.CreateObject("Persits.Jpeg")
Set fs = CreateObject("Scripting.FileSystemObject")
thumbSavePath = "/images/thumbnails/"
originalSavePath = "/images/events/"
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Save the files with his original names in a virtual path of the web server
' **************************************************************************
strTemp = fs.GetBaseName(fs.GetTempName)
strTemp = Right(strTemp, Len(strTemp) - 3)
strName = File.FileName
strName = strTemp + strName
End If
SavePath = originalSavePath & strName
file.SaveAS(SavePath)
' sample with a physical path
' file.SaveAs("c:\temp\" & file.FileName)
If Err Then
Response.Write("<strong>Unsuccessful upload: </strong>" & Err.Description & " " & CStr(Err.Number)& " " & Err.Source & "")
Response.Write("<strong>Click the back button to try again.</strong>")
Response.End
Else
jpeg.Open Server.MapPath(SavePath)
originalW = jpeg.OriginalWidth
originalH = jpeg.OriginalHeight
L = 100
If jpeg.OriginalWidth > jpeg.OriginalHeight Then
jpeg.Width = L
jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
jpeg.Height = L
jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If
jpeg.Sharpen 1, 250
'Draw frame: black, 2-pixel width
jpeg.Canvas.Pen.Color = &H000000
jpeg.Canvas.Pen.Width = 2
jpeg.Canvas.Brush.Solid = False
jpeg.Canvas.Bar 1, 1, jpeg.Width, jpeg.Height
adjustW = jpeg.Width
adjustH = jpeg.Height
If UCase(Right(strName, 3)) <> "JPG" Then
strName = strName & ".jpg"
End If
thumbName = "thumb" + strName
SavePath = thumbSavePath & thumbName
jpeg.Save Server.MapPath(SavePath)
jpeg.Close
SavePath = originalSavePath & strName
jpeg.Open Server.MapPath(SavePath)
L = 500
If jpeg.OriginalWidth > jpeg.OriginalHeight Then
jpeg.Width = L
jpeg.Height = jpeg.OriginalHeight * L / jpeg.OriginalWidth
Else
jpeg.Height = L
jpeg.Width = jpeg.OriginalWidth * L / jpeg.OriginalHeight
End If
jpeg.Sharpen 1, 250
'Draw Text
jpeg.Canvas.Font.Color = &HFF0000
jpeg.Canvas.Font.Family = "Courier New"
jpeg.Canvas.Font.Bold = True
'jpeg.Canvas.Font.Quality = 4
'jpeg.Canvas.Font.BKMode = "Opaque"
jpeg.Canvas.Font.Size = 25
jpeg.Canvas.Print 10, 10, "512ryders.com"
'Draw frame: black, 2-pixel width
jpeg.Canvas.Pen.Color = &H000000
jpeg.Canvas.Pen.Width = 2
jpeg.Canvas.Brush.Solid = False
jpeg.Canvas.Bar 1, 1, jpeg.Width, jpeg.Height
SavePath = originalSavePath & strName
jpeg.Save Server.MapPath(SavePath)
jpeg.Close
strSQL = "INSERT INTO tbl_Images (imageFileName, imageFilePath, imageFileSize, imageHits, imageWidth, imageHeight, thumbFileName, thumbFilePath, thumbWidth, thumbHeight) VALUES ('" & strName & "','"&originalSavePath&"','" & File.Size & "','" & hits & "','" & originalW & "','" & originalH & "','"& thumbName & "','"&thumbSavePath&"','" & adjustW & "','" & adjustH & "');"
adoCon.Execute(strSQL)
Response.Write(file.Name & ", ")
Response.Write("Size = " & file.Size & "bytes, ")
Response.Write(strName & ", ")
Response.Write(file.ContentType & "")
'Response.Write("<table><tr><td><img src='../images/thumbnails/"&thumbName&"' /></td>")
'Response.Write("<td><img src='../images/events/"&strName&"' /></td></tr></table>")
intCount = intCount + 1
End If
Next
Set fs = Nothing
Set jpeg = Nothing
%>
________
marijuana vaporizer