国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

自動采集程序

2020-07-27 13:25:29
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

<% 
  On Error Resume Next 
  Const uploadPath = "/uploads/" '文件存放路徑 
  Const allowFileExt = "jpg,wma,swf,gif" '允許被采集的文件類型 
  'Const allowFileSize = "200" 
  Function getFile(url) 
    If url = "" Then 
      Exit Function 
    Else 
      url = Trim(url) 
    End If 
    '獲取文件 
    fileExt = Lcase(Mid(url,Instrrev(url, ".")+1)) '文件類型 
    fileName = Lcase(Mid(url,Instrrev(url, "/")+1,Instrrev(url, ".")-Instrrev(url, "/")-1)) '無文件類型的文件名 
    newFilePath = getNow("Date") & "_" & Replace(FormatDateTime(Now(),3),":","") & "_" & cleanFileName(fileName) & "." & fileExt 
    if Instr(","&Lcase(allowFileExt)&",",","&fileExt&",") = 0 Then 
      getFile = "文件類型不允許" 
      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 <> 200 Then 
      getFile="獲取文件出錯" 
      Exit Function 
    Else 
      Set folder=Server.CreateObject("Scripting.FileSystemObject") 
      Dim folderName 
      folderName = getNow("Year")&getNow("Month") '文件夾 
      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 = "文件太大,不能保存!" 
        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"">采集成功</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="40" value="http://blog.xiaobin.net/uploads/200512/08_093616_01.gif">  
 <input type="Submit" name="Submit" value="采集 " class="button"> 
</form> 
<%end if%>

上一篇:js+asp總結

下一篇:登陸asp class

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 翁源县| 松原市| 宝坻区| 双柏县| 滕州市| 曲阳县| 桓台县| 乌鲁木齐县| 碌曲县| 灌云县| 嘉善县| 始兴县| 定襄县| 揭西县| 宁德市| 霍林郭勒市| 秦安县| 板桥市| 淮安市| 万源市| 鄂尔多斯市| 普宁市| 桐柏县| 阿拉善左旗| 丰宁| 区。| 东平县| 峨眉山市| 宝山区| 仁怀市| 田东县| 馆陶县| 全椒县| 中宁县| 金沙县| 光山县| 精河县| 滨海县| 云安县| 枞阳县| 碌曲县|