用最简单的语句写一个asp上传图片代码,上传到一个指定文件夹里?只写大概也可
4个回答
展开全部
upfile.asp 上传的图片存到images/upfile文件夹下。
<!--#include FILE="upfile"-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
if Request("menu")="up" then
On Error Resume Next
Set upl = Server.CreateObject("SoftArtisans.FileUp")
If -2147221005 = Err Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
set FileUP=new Upload_file
FileUP.GetDate(-1)
formPath="images/upfile/"
set file=FileUP.file("file")
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&file.FileExt
select case LCase(file.FileExt)
case "gif"
img="[img]"&cluburl&"/"&filename&"[/img]"
case "jpg"
img="[img]"&cluburl&"/"&filename&"[/img]"
case "swf"
img="[flash]"&cluburl&"/"&filename&"[/flash]"
case else
error2("Sorry ,this local server only supports GIF , JPG and SWF format of files\n does not support "&file.FileExt&" format of files")
end select
file.SaveToFile Server.mappath(filename)
set FileUP=nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
else
filename=""&year(date)&""&month(date)&""&day(date)&""&hour(time)&""&minute(time)&""&second(time)&""
select case ""&upl.ContentType&""
case "application/octet-stream"
error2("Unknown file format!")
case "image/gif"
types="gif"
case "image/pjpeg"
types="jpg"
case "application/x-shockwave-flash"
types="swf"
end select
filename="images/upfile/"&filename&"."&types&""
if types="gif" or types="jpg" then
img="[img]"&cluburl&"/"&filename&"[/img]"
elseif types="swf" then
img="[flash]"&cluburl&"/"&filename&"[/flash]"
else
error2("Sorry ,this local server only supports GIF , JPG and SWF format of files\n does not support "&upl.ContentType&"format of files")
end if
upl.SaveAs Server.mappath(""&filename&"")
set upl=nothing
End If
response.write "<SCRIPT>parent.myform.pic.value='admin/"&filename&"'</SCRIPT>"
responseend
else
%>
<body topmargin=0>
<table cellpadding=0 cellspacing=0 width=100% height="20">
<form enctype=multipart/form-data method=post action=upfile.asp?menu=up>
<tr><td>
<input type=file style=FONT-SIZE:9pt name=file size="2"> <input style=FONT-SIZE:9pt type="submit" value="Upload" name=Submit>
</td></tr></form></table>
<%
end if
%>
<!--#include FILE="upfile"-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
if Request("menu")="up" then
On Error Resume Next
Set upl = Server.CreateObject("SoftArtisans.FileUp")
If -2147221005 = Err Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
set FileUP=new Upload_file
FileUP.GetDate(-1)
formPath="images/upfile/"
set file=FileUP.file("file")
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&file.FileExt
select case LCase(file.FileExt)
case "gif"
img="[img]"&cluburl&"/"&filename&"[/img]"
case "jpg"
img="[img]"&cluburl&"/"&filename&"[/img]"
case "swf"
img="[flash]"&cluburl&"/"&filename&"[/flash]"
case else
error2("Sorry ,this local server only supports GIF , JPG and SWF format of files\n does not support "&file.FileExt&" format of files")
end select
file.SaveToFile Server.mappath(filename)
set FileUP=nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
else
filename=""&year(date)&""&month(date)&""&day(date)&""&hour(time)&""&minute(time)&""&second(time)&""
select case ""&upl.ContentType&""
case "application/octet-stream"
error2("Unknown file format!")
case "image/gif"
types="gif"
case "image/pjpeg"
types="jpg"
case "application/x-shockwave-flash"
types="swf"
end select
filename="images/upfile/"&filename&"."&types&""
if types="gif" or types="jpg" then
img="[img]"&cluburl&"/"&filename&"[/img]"
elseif types="swf" then
img="[flash]"&cluburl&"/"&filename&"[/flash]"
else
error2("Sorry ,this local server only supports GIF , JPG and SWF format of files\n does not support "&upl.ContentType&"format of files")
end if
upl.SaveAs Server.mappath(""&filename&"")
set upl=nothing
End If
response.write "<SCRIPT>parent.myform.pic.value='admin/"&filename&"'</SCRIPT>"
responseend
else
%>
<body topmargin=0>
<table cellpadding=0 cellspacing=0 width=100% height="20">
<form enctype=multipart/form-data method=post action=upfile.asp?menu=up>
<tr><td>
<input type=file style=FONT-SIZE:9pt name=file size="2"> <input style=FONT-SIZE:9pt type="submit" value="Upload" name=Submit>
</td></tr></form></table>
<%
end if
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用ASP.NET可以实现 几句语句 上传 ASP需要很多
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用无惧上传类即可,或者搜无组件上传
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我这有.加我:254105736
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询