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>
<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>
google搜索:远程图片自动上传
声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。如有疑问请与站长联系。
相关链接更多...
- Blog设计的7个趋势2006-5-9
- 正则小偷的部份核心函数2006-5-9
- asp如何检测自己网站的错误2006-5-9
- ASP中有关timeout超时的体会2006-5-9
- 用递归算法实现ASP程序用fso对硬盘上某个路径下目录和文件的遍历2006-5-9
- asp远程图片自动上传到服务器2006-5-9
- 实例讲解ASP实现抓取网上房产信息2006-5-9
- ASP实用技巧:强制刷新和判断文件地址2006-5-9
- 在ASP应用程序中限制重复提交同一表单2006-5-9
- 在ASP应用程序中加入智能搜索2006-5-9
网友评论
这个东西nb
NB个毛,只能创建文件夹,文件根本传不上去
这个东西nb
NB个毛,只能创建文件夹,文件根本传不上去
全站精华
- 韩国品牌YSB夏装 冷艳美人异国风情(3)[图]
- MIKE H的CG插画作品欣赏(3)[图]
- MIKE H的CG插画作品欣赏(2)[图]
- MIKE H的CG插画作品欣赏(1)[图]
- 塑造完美—最美丽的CG女孩 [图]
- Trapped 精彩插画作品(3)[图]
- Trapped 精彩插画作品(2)[图]
- Trapped 精彩插画作品(1)[图]
- Trapped 精彩插画作品(1)[图]
- 韩国插画小品(3)[图]
- 韩国插画小品(1)[图]
- 乡村树花草摄影作品[图]
- 香港顶尖室内设计师梁志天作品[图]
- 天使的嫁衣--婚纱装欣赏[图]
- 经典样本设计欣赏(国人作品)3[图]
- asp远程图片自动上传到服务器
- 人像摄影:《炫影》(1)[图]
- 人像摄影:《炫影》(2)[图]
- 人像摄影:《炫影》(3)[图]
- 景观设计城市公园:浙江黄岩永宁公园(3)[图]
- 朱峰手绘插画-角色篇(Characters)(一)[图]
- 朱峰手绘插画-角色篇(Characters)(十三)[图]
- 朱峰手绘插画欣赏--场景篇(Environments)(1)[图]
- 经典室内设计作品--宫殿风格1[图]
- 地产广告1[图]
- Google SiteMap生成工具 (ASP & PHP)
- ASP生成具有分页的静态网页
- 《星战》原版手绘作品欣赏--电影中看不到的经典[图]
- 经典海报设计欣赏1[图]
- 经典T恤设计欣赏3[图]
图文精彩

【2006-5-8 11:37:48】
韩国品牌YSB夏装 冷艳美人异国风情(3)
韩国品牌YSB夏装 冷艳美人异国风情(3)

【2006-5-8 9:52:42】
MIKE H的CG插画作品欣赏(1)
MIKE H的CG插画作品欣赏(1)
![经典样本设计欣赏(国人作品)1[图]--平面广告](http://www.fansart.com/uploadfile/200642664631465.jpg)
【2006-4-26 17:57:18】
经典样本设计欣赏(国人作品)1
经典样本设计欣赏(国人作品)1

【2006-4-26 14:27:13】
新锐CG插画 Monday to Friday
新锐CG插画 Monday to Friday

【2006-4-26 13:34:46】
Natascha Roeoesli的人物CG插画作品欣赏(1)
Natascha Roeoesli的人物CG插画作品欣赏(1)
![水木清华地产广告欣赏[图]--平面广告](http://www.fansart.com/uploadfile/200642634295921.jpg)
【2006-4-26 9:31:54】
水木清华地产广告欣赏
水木清华地产广告欣赏
![2006夏日流行时尚,创意无限街头华丽[图]--时装魅影](http://www.fansart.com/uploadfile/200642261089093.jpg)
【2006-4-22 16:46:51】
2006夏日流行时尚,创意无限街头华丽
2006夏日流行时尚,创意无限街头华丽
![万科西山庭院.格.沉.尊[图]--平面广告](http://www.fansart.com/uploadfile/200642133015939.jpg)
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
万科西山庭院.格.沉.尊
![泊林花园推广故事绘本(2)[图]--CG插画](http://www.fansart.com/uploadfile/200642042197577.jpg)
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(2)
![泊林花园推广故事绘本(1)[图]--CG插画](http://www.fansart.com/uploadfile/200642041664949.jpg)
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
泊林花园推广故事绘本(1)
![房地产广告设计-之水墨风格1[图]--平面广告](http://www.fansart.com/uploadfile/200641457308753.jpg)
【2006-4-14 15:56:06】
房地产广告设计-之水墨风格1
房地产广告设计-之水墨风格1
![溯源居广告欣赏--小红人[图]--平面广告](http://www.fansart.com/uploadfile/200641453136345.jpg)
【2006-4-14 14:45:57】
溯源居广告欣赏--小红人
溯源居广告欣赏--小红人
![cg插画欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641433658593.jpg)
【2006-4-14 9:21:18】
cg插画欣赏
cg插画欣赏
![yashasi插画作品欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641366906025.jpg)
【2006-4-13 18:32:29】
yashasi插画作品欣赏
yashasi插画作品欣赏
![北邦插画欣赏(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641335800545.jpg)
【2006-4-13 9:49:02】
北邦插画欣赏(1)
北邦插画欣赏(1)
![高傲的玫瑰-温碧霞[图]--摄影艺术](http://www.fansart.com/uploadfile/200641232299455.jpg)
【2006-4-12 8:58:34】
高傲的玫瑰-温碧霞
高傲的玫瑰-温碧霞
![国粹京剧脸谱表情[图]--界面设计](http://www.fansart.com/uploadfile/200641164370797.jpg)
【2006-4-11 17:51:33】
国粹京剧脸谱表情
国粹京剧脸谱表情
![回忆紫禁城里那些逝去的[图]--中国艺术](http://www.fansart.com/uploadfile/200641159463469.jpg)
【2006-4-11 16:34:31】
回忆紫禁城里那些逝去的
回忆紫禁城里那些逝去的
![非常可爱的儿童插画(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641157447221.jpg)
【2006-4-11 15:59:16】
非常可爱的儿童插画(1)
非常可爱的儿童插画(1)

【2006-4-11 15:49:41】
荷兰著名画家Anton Pieck插画
荷兰著名画家Anton Pieck插画
RE:asp远程图片自动上传到服务器--asp编程技术
回复者:匿名 时间:2006-5-9