Check upload picture is legitimate function, trojan change suffix name, picture plus malicious code are not escape _ application skills

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.