Copy Code code as follows:
<%
On Error Resume Next
Const Uploadpath = "/uploads/" File Store path
Const allowfileext = "Jpg,wma,swf,gif" allows file types to be collected
' Const allowfilesize = ' 200 '
Function getFile (URL)
If url = "" Then
Exit Function
Else
url = Trim (URL)
End If
' Get file
Fileext = Lcase (Mid (Url,instrrev (URL, ".") +1)) ' File type
FileName = Lcase (Mid (Url,instrrev (URL, "/") +1,instrrev (URL, ".") -instrrev (URL, "/")-1) ' No file type filename
Newfilepath = Getnow ("Date") & "_" & Replace (Now (), 3), ":", "") & "_" & Cleanfilename ( FileName) & "." & Fileext
If Instr ("," &lcase (Allowfileext) & ",", "," &fileExt& ",") = 0 Then
GetFile = "File type not allowed"
Exit Function
End If
Set xmlhttp = Server.CreateObject ("Microsoft.XMLHTTP")
Xmlhttp.open "Get", Url,false
Xmlhttp.send
' While Xmlhttp.readystate <> 4
' Xmlhttp.waitforresponse 1000
' Wend
If xmlhttp.status <> Then
getfile= "Get file Error"
Exit Function
Else
Set folder=server.createobject ("Scripting.FileSystemObject")
Dim FolderName
FolderName = Getnow ("year") &getnow ("Month") folder
If folder. FolderExists (Server.MapPath (Uploadpath)) =false Then
Folder. CreateFolder Server.MapPath (Uploadpath)
End If
If folder. FolderExists (Server.MapPath (Uploadpath & FolderName)) =false Then
Folder. CreateFolder Server.MapPath (Uploadpath & FolderName)
End If
Set folder=nothing
File=xmlhttp. Responsebody
If LenB (file) > Allowfilesize Then
GetFile = "File is too large to save!" "
Exit Function
Else
Set objadostream=server.createobject ("ADODB. Str "&" Eam ")
Objadostream.open ()
Objadostream.type=1
Objadostream.write (file)
Objadostream.savetofile (Server.MapPath (Uploadpath & FolderName & "/" & Newfilepath))
Objadostream.seteos
Set objadostream=nothing
getfile= "<a href=" "&uploadpath & FolderName &"/"& newfilepath&" "target=" "_balnk" "> Acquisition Success </a> "
End If
End If
Set xmlhttp=nothing
End Function
%>
<script runat= "Server" language= "JScript" >
function Cleanfilename (str) {
str = str.replace (/[^_\.a-za-z\d]/ig, "");
str = str.replace (/^[\/\.] +/,"");
return str;
}
function Getnow (n)
{
D = new Date ();
Switch (n)
{
Case "Year":
return D.getyear ();
Case "Month":
Return (D.getmonth () + 1);
Case "Date":
return D.getdate ();
}
}
</script>
<%if request ("do") = "GetFile" and request ("file") <> "" Then
Response.Write (GetFile (Request ("file"))
Else%>
<form id= "Gform" method= "post" action= "Do=getfile" style= "Display:inline" >
<input name= "file" type= "input" style= font-size:12px; "size=" value= "Yun_qi_img/08_093616_01.gif" >
<input type= "Submit" name= "Submit" Value= "collection" class= "button" >
</form>
<%end if%>