Automatic acquisition Procedures _ Thieves/collection

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

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.