No-component upload vulnerability fix

Source: Internet
Author: User

Sub upload_0 () set upload = new UpFile_Class "creates an upload object
Upload. GetDate (int (Forum_Setting (56) * 1024) 'to obtain the uploaded data, not limited to size
ICount = 0

If upload. err> 0 then
Select case upload. err
Case 1
Response. Write "select the file you want to upload first [<a href = # onclick = history. go (-1)> re-upload </a>]"
Case 2
Response. write "the image size exceeds the limit" & Forum_Setting (56) & "K [<a href = # onclick = history. go (-1)> re-upload </a>]"
End select
Exit sub
Else
FormPath = upload. form ("filepath ")
"Add (/) after the Directory (/)
If right (formPath, 1) <> "/" then formPath = formPath &"/"

For each formName in upload. file "lists all uploaded files.
Set file = upload. file (formName) "to generate a file object
If file. filesize <100 then
Response. write "select the image you want to upload first [<a href = # onclick = history. go (-1)> re-upload </a>]"
Response. end
End if

FileExt = lcase (file. FileExt)
If CheckFileExt (fileEXT) = false then
Response. write "the file format is incorrect [<a href = # onclick = history. go (-1)> re-upload </a>]"
Response. end
End if

Randomize
RanNum = int (90000 * rnd) + 10000
Filename = formPath & year (now) & month (now) & day (now) & hour (now) & minute (now) & second (now) & ranNum &". "& fileExt
'Test whether the file character is invalid

Dim R_Char, R_ I
For R_ I = 1 to Len (filename)
R_Char = ASC (MID (filename, R_ I, 1 ))
If R_Char = 0 then
Response. write "Is it good to do something meaningful? hackers are studying technology, not damaging"
Response. end
End if
Next

If file. FileSize> 0 then "if FileSize> 0, file data exists.
File. SaveToFile Server. mappath (filename) "save the file
'Response. write file. FilePath & file. FileName & "(" & file. FileSize & ") =>" & formPath & File. FileName & "is successful! <Br>"
Response. write "<script> parent.doc ument. forms [0]. myface. value = '" & FileName & "' </script>"
ICount = iCount + 1
End if
Set file = nothing
Next
Set upload = nothing
Session ("upface") = "done"
Htmend iCount & "file upload is complete !"

End ifend sub
 

 

Related Article

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.