Today tried the next AspJpeg component, found that the use of ASPJPEG components to deal with abnormal picture files when there will be errors, oh, this just allows us to check the legality of the picture, I have to encapsulate into a function ~
Copy Code code as follows:
'-------------------------------------------
' Function name: chkimg
' Function: Check if picture file is legal
' Parameters: IMG, picture path
' Return value: Boolean type
' Condition: server must support AspJpeg
'-------------------------------------------
Function chkimg (IMG)
On Error Resume Next
Chkimg=true
If IsNull (img) then Chkimg=false:exit function
Set chkjpeg = Server.CreateObject ("Persits.jpeg")
Chkpath = Server.MapPath (IMG)
Chkjpeg.open Chkpath
If ERR Then
Chkimg=false
End If
If err.number<>0 Then Err.Clear
Set chkjpeg=nothing
End Function
Because AspJpeg can only handle files already on the server, we can do this in the actual process: first upload the picture to a temporary folder, and then check the legality of the picture, if legal, copy the picture to the picture save directory, delete temporary files and return upload success information, if illegal, Deletes the temporary file directly and returns an error warning.