艺术迷(fansart.com) 首页 收藏本站 RSS频道
艺术迷首页 -> 网页设计 -> asp远程图片自动上传到服务器--asp编程技术
2006-5-9   作者:   来源:互联网   点击:2446
页面功能: 【评论】有错就点】 【字体: 】 【打印】 【关闭【收藏本页】
asp远程图片自动按文件夹上传到服务器
<html>
<head>
<meta http-equiv="content-Type" content="text/html; charset=gb2312">
<title>远程图片自动按文件夹上传到服务器</title>
<style type=text/css>
a { text-decoration: none; color: blue }
a:hover { text-decoration: underline }
body { scrollbar-base-color: #F8F8F8; scrollbar-arrow-color: #698CC3; font-size: 12pt; background-color: #ffffff }
</style>
<body topmargin="0" bgcolor="#F9F9F9">
<%
Server.ScriptTimeOut=99999
savepath="testupfile" '图片保存路径‚可以根据自己的需要‚进行修改‚如没有创建此文件夹‚系统将自动创建
imgpath=request("imgpath")
if imgpath="" then
response.write "<form name=mofeiform method=post action=''><input type=text name=imgpath size=35> <input type=submit name=Submit001 value=上传></form><br>在输入框中输入远程图片地址‚如图片不存在‚程序自动放弃本次操作.<BR>"
else
filepath02=mofeifoldfso(savepath)
savepath=savepath&"\"&year(now())&month(now())
filepath02=mofeifoldfso(savepath)
urname01=myreplace(imgpath)
end if

function myreplace(str)
newstr=str
set objregEx = new RegExp
objregEx.IgnoreCase = true
objregEx.Global = true
objregEx.Pattern = "http://(.+?)\.(jpg|gif|png|bmp)" '定义文件后缀‚可以增加你需要的后缀‚按规律增加.
set matches = objregEx.execute(str)
for each match in matches
newstr=replace(newstr‚match.value‚saveimg(match.value))
next
myreplace=newstr
end function

function saveimg(url)
temp=split(url‚".")
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&temp(ubound(temp))
'文件名重命名结束
set xmlhttp=server.createobject("Microsoft.XMLHTTP")
xmlhttp.open "get"‚url‚false
xmlhttp.send
img=xmlhttp.ResponseBody
set xmlhttp=nothing
set objAdostream=server.createobject("ADODB.Stream")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(img)
if objAdostream.size<200 then
response.write "<font color=red>没找到内容!</font>[<a href=# onclick=history.go(-1)>返回</a>]"
response.end
end if
objAdostream.SaveToFile(server.mappath(savepath&"\"&filename))
objAdostream.SetEOS
set objAdostream=nothing
imgpath01=savepath&"\"&filename '返回图片路径
imgpath01=replace(imgpath01‚"\"‚"/")
response.write ("图片上传成功! [<a href=# onclick=history.go(-1)>继续上传</a>]")
response.write ("<br><img src="&imgpath01&" border=0 alt=默飞制作>") '根据你的系统需要‚更改返回方式.
end function

Function mofeifoldfso(mpath)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(server.Mappath(mpath)) then fso.Createfolder(server.mappath(mpath))
set fso=nothing
End Function
%>

</body>
</html>




页面功能: 【评论】有错就点】 【字体: 】 【打印】 【关闭【收藏本页】
声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。如有疑问请与站长联系。
网友评论

RE:asp远程图片自动上传到服务器--asp编程技术

 回复者:匿名 时间:2006-5-9
这个东西nb

RE:asp远程图片自动上传到服务器--asp编程技术

 回复者:匿名 时间:2006-8-21
NB个毛,只能创建文件夹,文件根本传不上去

RE:asp远程图片自动上传到服务器--asp编程技术

 回复者:匿名 时间:2006-5-9
这个东西nb

RE:asp远程图片自动上传到服务器--asp编程技术

 回复者:匿名 时间:2006-8-21
NB个毛,只能创建文件夹,文件根本传不上去
发表评论
您的姓名: 匿名发送
电子邮件:
评论内容:
不能超过100个字符



所有留言只代表网友个人观点,不代表本站观点。
请各位遵纪守法并注意语言文明。
新闻搜索
关 键 词:
搜索范围:
全站精华
图文精彩
MIKE
【2006-5-8 9:52:42】
MIKE H的CG插画作品欣赏(1)
新锐CG插画
【2006-4-26 14:27:13】
新锐CG插画 Monday to Friday
水木清华地产广告欣赏[图]--平面广告
【2006-4-26 9:31:54】
水木清华地产广告欣赏
万科西山庭院.格.沉.尊[图]--平面广告
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
泊林花园推广故事绘本(2)[图]--CG插画
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(1)[图]--CG插画
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
溯源居广告欣赏--小红人[图]--平面广告
【2006-4-14 14:45:57】
溯源居广告欣赏--小红人
cg插画欣赏[图]--CG插画
【2006-4-14 9:21:18】
cg插画欣赏
yashasi插画作品欣赏[图]--CG插画
【2006-4-13 18:32:29】
yashasi插画作品欣赏
北邦插画欣赏(1)[图]--CG插画
【2006-4-13 9:49:02】
北邦插画欣赏(1)
高傲的玫瑰-温碧霞[图]--摄影艺术
【2006-4-12 8:58:34】
高傲的玫瑰-温碧霞
国粹京剧脸谱表情[图]--界面设计
【2006-4-11 17:51:33】
国粹京剧脸谱表情
回忆紫禁城里那些逝去的[图]--中国艺术
【2006-4-11 16:34:31】
回忆紫禁城里那些逝去的
非常可爱的儿童插画(1)[图]--CG插画
【2006-4-11 15:59:16】
非常可爱的儿童插画(1)
荷兰著名画家Anton
【2006-4-11 15:49:41】
荷兰著名画家Anton Pieck插画