时间:2021-05-26
复制代码 代码如下:
<%
'================================================
'函数名:SaveRemoteFile
'作用:保存远程文件到本地
'参数:strFileName----保存文件的名称
'strRemoteUrl----远程文件URL
'返回值:布尔值True/False
'================================================
FunctionSaveRemoteFile(ByValstrFileName,ByValstrRemoteUrl)
DimoStream,Retrieval,GetRemoteData
SaveRemoteFile=False
OnErrorResumeNext
SetRetrieval=Server.CreateObject("Microsoft.XMLHTTP")
Retrieval.Open"GET",strRemoteUrl,False,"",""
Retrieval.Send
IfRetrieval.readyState<>4ThenExitFunction
IfRetrieval.Status>300ThenExitFunction
GetRemoteData=Retrieval.ResponseBody
SetRetrieval=Nothing
IfLenB(GetRemoteData)>100Then
SetoStream=Server.CreateObject("Adodb.Stream")
oStream.Type=1
oStream.Mode=3
oStream.Open
oStream.WriteGetRemoteData
oStream.SaveToFileServer.MapPath(strFileName),2
oStream.Cancel
oStream.Close
SetoStream=Nothing
Else
ExitFunction
EndIf
IfErr.Number=0Then
SaveRemoteFile=True
Else
Err.Clear
EndIf
EndFunction
%>
复制代码 代码如下:
<%
ClassDownload_Cls
PrivatesUploadDir
PrivatenAllowSize
PrivatesAllowExt
PrivatesOriginalFileName
PrivatesSaveFileName
PrivatesPathFileName
PublicPropertyGetRemoteFileName()
RemoteFileName=sOriginalFileName
EndProperty
PublicPropertyGetLocalFileName()
LocalFileName=sSaveFileName
EndProperty
PublicPropertyGetLocalFilePath()
LocalFilePath=sPathFileName
EndProperty
PublicPropertyLetRemoteDir(ByValstrDir)
sUploadDir=strDir
EndProperty
PublicPropertyLetAllowMaxSize(ByValintSize)
nAllowSize=intSize
EndProperty
PublicPropertyLetAllowExtName(ByValstrExt)
sAllowExt=strExt
EndProperty
PrivateSubClass_Initialize()
OnErrorResumeNext
Script_Object="Scripting.FileSystemObject"
sUploadDir="UploadFile/"
nAllowSize=500
sAllowExt="gif|jpg|png|bmp"
EndSub
PublicFunctionChangeRemote(sHTML)
OnErrorResumeNext
Dims_Content
s_Content=sHTML
OnErrorResumeNext
Dimre,s,RemoteFileUrl,SaveFileName,SaveFileType
Setre=NewRegExp
re.IgnoreCase=True
re.Global=True
re.Pattern="((http|https|ftp|rtsp|mms):(\/\/|\\\\){1}(([A-Za-z0-9_-])+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*\/)((\S)+[.]{1}("&sAllowExt&")))"
Sets=re.Execute(s_Content)
Dima_RemoteUrl(),n,i,bRepeat
n=0
'转入无重复数据
ForEachRemoteFileUrlIns
Ifn=0Then
n=n+1
ReDima_RemoteUrl(n)
a_RemoteUrl(n)=RemoteFileUrl
Else
bRepeat=False
Fori=1ToUBound(a_RemoteUrl)
IfUCase(RemoteFileUrl)=UCase(a_RemoteUrl(i))Then
bRepeat=True
ExitFor
EndIf
Next
IfbRepeat=FalseThen
n=n+1
ReDimPreservea_RemoteUrl(n)
a_RemoteUrl(n)=RemoteFileUrl
EndIf
EndIf
Next
'开始替换操作
DimnFileNum,sContentPath,strFilePath
sContentPath=RelativePath2RootPath(sUploadDir)
nFileNum=0
Fori=1Ton
SaveFileType=Mid(a_RemoteUrl(i),InStrRev(a_RemoteUrl(i),".")+1)
SaveFileName=GetRndFileName(SaveFileType)
strFilePath=sUploadDir&SaveFileName
IfSaveRemoteFile(strFilePath,a_RemoteUrl(i))=TrueThen
nFileNum=nFileNum+1
IfnFileNum>0Then
sOriginalFileName=sOriginalFileName&"|"
sSaveFileName=sSaveFileName&"|"
sPathFileName=sPathFileName&"|"
EndIf
sOriginalFileName=sOriginalFileName&Mid(a_RemoteUrl(i),InStrRev(a_RemoteUrl(i),"/")+1)
sSaveFileName=sSaveFileName&SaveFileName
sPathFileName=sPathFileName&sContentPath&SaveFileName
s_Content=Replace(s_Content,a_RemoteUrl(i),sContentPath&SaveFileName,1,-1,1)
EndIf
Next
ChangeRemote=s_Content
EndFunction
PublicFunctionRelativePath2RootPath(url)
'这个主要是实现../转换为实际路径
DimsTempUrl
sTempUrl=url
IfLeft(sTempUrl,1)="/"Then
RelativePath2RootPath=sTempUrl
ExitFunction
EndIf
DimsWebEditorPath
sWebEditorPath=Request.ServerVariables("SCRIPT_NAME")
sWebEditorPath=Left(sWebEditorPath,InStrRev(sWebEditorPath,"/")-1)
DoWhileLeft(sTempUrl,3)="../"
sTempUrl=Mid(sTempUrl,4)
sWebEditorPath=Left(sWebEditorPath,InStrRev(sWebEditorPath,"/")-1)
Loop
RelativePath2RootPath=sWebEditorPath&"/"&sTempUrl
EndFunction
PublicFunctionGetRndFileName(sExt)
DimsRnd
Randomize
sRnd=Int(900*Rnd)+100
GetRndFileName=Year(Now)&Month(Now)&Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&sRnd&"."&sExt
EndFunction
EndClass
%>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
0ThensTempContent=Newasp.CutMatchContent(strTemp,"{$ReadArticleList(",")}",1)nTe
下载Tinder应用。你可以从苹果AppStore或谷歌Play商店中下载Tinder,也可以直接从Tinder官网下载应用。Tinder的下载是免费的。使用F
想要在吉吉影音中下载影片却不会操作怎么办呢?以下教程就为大伙带来了吉吉影音中下载影片的具体流程介绍。 1、开吉吉影音,搜索相关的电影观看,看完发现非常好看
Linux虚拟机:VMware+ubuntu16.04.4windows本机:NavicatforMySQL1、虚拟机中下载安装MySQLVMware下载安装和
海信电视下载软件是在自带应用商店“聚好用”中下载。 DLNA的全称是DIGITALLIVINGNETWORKALLIANCE(数字生活网络联盟)。其宗旨是En