aspjpeg error

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
 
With On Error Resume Next

file1, Size = 18594bytes, DBCCEuc_logo.jpg, image/jpeg
Unsuccessful upload: You must first call Open or OpenBinary. -2147221503 Persits.Jpeg.1
Click the back button to try again.

Without On Error Resume Next

Error Type:
Persits.Jpeg.1 (0x8004002A)
Empty input file
/512ryders/admin/process_event_images.asp, line 108

the error is at this line(beginning of jpeg statements)
jpeg.Open Server.MapPath(SavePath)


No matter what image I use
 
I noticed that your filename is wrapped in an IF statement (If not file.IsMissing Then). Are you sure strTemp contains a valid file name?
 
Wayhome said:
I noticed that your filename is wrapped in an IF statement (If not file.IsMissing Then). Are you sure strTemp contains a valid file name?

Yeah I have actually changed upload components to aspupload and changed that line to If NOT FILE IS NOTHING THEN, and also changed a line to
file.SaveAs Server.MapPath(string)
 
Back
Top