主题: 求asp远程图片本地化插件
作者: 小马, 发布日期: 2013-03-12 16:47:36, 浏览数: 4060
求asp远程图片本地化插件,求asp远程图片本地化插件,求asp远程图片本地化插件
作者: 小浪子, 发布日期: 2013-03-12 17:54:22
官方目前没有。只能自行开发。
回复
作者: Victor, 发布日期: 2013-03-14 09:03:43

我目前使用的ASP程序,我自己写了一个将远程图片保存到本地目录的,不知道是否是你想要。

 

回复
作者: 小马, 发布日期: 2013-03-15 15:49:30
回复Victor:嗯 是的  哥们能不能把这个插件给共享一下啊  拜托了  411089403@qq.com  谢谢
回复
作者: Victor, 发布日期: 2013-03-16 13:21:03
<%
Const sFileExt="jpg|gif|bmp|png"
Function ReplaceRemoteUrl(sHTML, sSaveFilePath, sFileExt)
     Dim s_Content
     s_Content = sHTML
     If IsObjInstalled("Microsof" & "t.X" & "MLHTTP") = False then
         ReplaceRemoteUrl = s_Content
         Exit Function
     End If     
     Dim re, RemoteFile, RemoteFileurl,SaveFileName,SaveFileType,arrSaveFileNameS,arrSaveFileName,sSaveFilePaths
     Set re = new RegExp
     re.IgnoreCase = True
     re.Global = True
     re.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\){1}((\w)+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*\/)((\S)+[.]{1}(" & sFileExt & ")))"
     Set RemoteFile = re.Execute(s_Content)
     For Each RemoteFileurl in RemoteFile
		 arrSaveFileName = Split(RemoteFileurl,".")
  		 SaveFileType=arrSaveFileName(UBound(arrSaveFileName))
		 RanNum=Int(900*Rnd)+100
         arrSaveFileName = Year(Now()) & Right("0" & Month(Now()),2)&  Right("0" & Day(Now()),2) & Right("0" & Hour(Now()),2) & Right("0" & Minute(Now()),2) & Right("0" & Second(Now()),2) &ranNum&"."&SaveFileType
  sSaveFilePaths= sSaveFilePath
         SaveFileName = sSaveFilePaths & arrSaveFileName 
		 if SaveRemoteFile(""&SaveFileName&"",""&RemoteFileurl&"") then 
		 response.Write ""&SaveFileName&" 图片保存成功. <br />"
		 s_Content = Replace(s_Content,RemoteFileurl,SaveFileName)
		 else 
		 Response.write ""&RemoteFileurl&" 图片保存<font color='#FF0000'>失败</font>.<br />" 
		 end if
     Next
     ReplaceRemoteUrl = s_Content
End Function

function SaveRemoteFile(s_LocalFileName,s_RemoteFileUrl)
     Dim Ads, Retrieval, GetRemoteData
     On Error Resume Next
     Set Retrieval = Server.CreateObject("Microso" & "ft.XM" & "LHTTP")
     With Retrieval
         .Open "Get", s_RemoteFileUrl, False, "", ""
         .Send
         GetRemoteData = .ResponseBody
     End With
     Set Retrieval = Nothing
     Set Ads = Server.CreateObject("Ado" & "db.Str" & "eam") 
     With Ads
         .Type = 1
         .Open
         .Write GetRemoteData
         .SaveToFile Server.MapPath(s_LocalFileName), 2
         .Cancel()
         .Close()
     End With
     Set Ads=nothing	 
	 if err <> 0 then 
	 SaveRemoteFile = false 
	 err.clear 
	 else 
	 SaveRemoteFile = true 
	 end if
End Function
Function IsObjInstalled(s_ClassString)
     On Error Resume Next
     IsObjInstalled = False
     Err = 0
     Dim xTestObj
     Set xTestObj = Server.CreateObject(s_ClassString)
     If 0 = Err Then IsObjInstalled = True
     Set xTestObj = Nothing
     Err = 0
End Function
%>

以上为主程序

 

在编辑框下加入代码:

<input name="sSaveFileSelect" type="checkbox"  id="sSaveFileSelect" value="1">保存远程图片到本地

 

提交保存代码:

<%
sSaveFileSelect=request.Form("sSaveFileSelect")
sub_content=request.form("content")
if sSaveFileSelect=1 then
Set fso=Server.CreateObject("Scripting.FileSystemObject")
yy=right(year(date),4)
mm=right("00"&month(date),2)
dd=right("00"&day(date),2)
uploaddate=yy&mm&dd
uploadpath="../uploadfiles/image/"&uploaddate&"/"
If Not fso.FolderExists(Server.mappath(uploadpath)) Then
  fso.CreateFolder(Server.mappath(uploadpath))
End If
content=ReplaceRemoteUrl(sub_content,uploadpath,sFileExt)
else
content=sub_content
end if
%>


原文出处:http://www.andasen.net/news/news-69.html

 

程序打包百度网盘下载:

http://pan.baidu.com/share/link?shareid=398032&uk=335874970

 

回复
作者: 小浪子, 发布日期: 2013-03-16 17:22:29
回复Victor:呵呵。其实可以参考新云的程序。实现一勾选远程自动保存。就开始类似ajax的保存。不用在提交的时候保存。
回复
作者: yoja365com, 发布日期: 2013-04-07 22:03:37

ASP本地化,网上已经有提供,查看:http://www.andasen.net/news/news-69.html



友家商城-http://www.yoja365.com   http://yoja365.taobao.com

回复
发表新帖 发表回复