This function is to use "Transformation ASP no component Upload Program 2.0" upload files.
Core functions:
<%
'''''==============================
' Function name: upfile
' Function: Use ' transformation upload component ' to upload files to server
' Parameter: File1 file object
' Savepath file to save relative path, such as '. /"record at the top level," "the same directory
' MaxSize allows the maximum file size to be uploaded, in kilobytes KB. is 0 Unlimited.
' Savetype allows the type of file to be uploaded, 0 unrestricted, restricted format. such as. Jpg|. bmp|. Zip
' Return value: Returns the upload information, but also can set the return value according to the need
' Premise: Set upload=new upload_5xsoft ' Build upload Object
' Set File1=upload.file (' file1 ') ' generates a File object
' Designer:suercool
function Upfile (file1,savepath,maxsize,savetype)
If File1.filename= "" and file1.filesize<=0 Then
upfile= "<script language= ' JavaScript ' >alert (' file does not exist! ') </script> "
Exit function
End If
If maxsize<> "0" and FILE1.FILESIZE>CLNG (maxsize) *1024 Then
upfile= "<script language= ' JavaScript ' >alert (' file size exceeds the limit, maximum upload only" & CStr (maxsize) & "KB files! ') </script> "
Exit function
End If
Dim Filename,filetype
Filename=file1.filename
Filetype=getfiletype (filename)
If savetype<> "0" Then
Dim Arrtype,i,foundtype
Arrtype=split (Savetype, "|")
Foundtype=false
For i = 0 To UBound (arrtype)
If LCase (Arrtype (i)) =filetype then
Foundtype=true
Exit For
End If
Next
If not Foundtype then
upfile= "<script language= ' JavaScript ' >alert (' file format is not accurate, only allowed to upload ' & savetype & ' Format Files! ') </script> "
Exit function
End If End If
Randomize ()
Filepath=savepath&year (now) &month-&day (now) &hour (now) &minute (now) &second (now) & Int (rnd*9999) &filetype
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.