如何在asp中使用无组件上传文件?!
我是新手`麻烦说详细一点具体的使用过程,怎么使用,如果有代码,又是如何使用代码的,使用哪些代码~?!麻烦了!!...
我是新手`麻烦说详细一点具体的使用过程,怎么使用,如果有代码,又是如何使用代码的,使用哪些代码~?! 麻烦了!!
展开
2个回答
展开全部
2个文件
第一个文件:
<html>
<body>
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.asp" method=post>
<input type=file name=mefile><br>
<input type=submit name=okvalue="OK">
</form>
</center>
</body>
</html>
第二个:
<%
sub pic()
if Request.QueryString("submit")="pic" then
uploadpath="image/face/"
uploadsize="2048"
uploadtype="jpg/gif/png/bmp"
Set Uprequest=new UpLoadClass
Uprequest.SavePath=uploadpath
Uprequest.MaxSize=uploadsize*1024
Uprequest.FileType=uploadtype
AutoSave=true
Uprequest.open
if Uprequest.form("file_Err")<>0 then
select case Uprequest.form("file_Err")
case 1:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件超过"&uploadsize&"k [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
case 2:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件格式不对 [<a href='javascript:history.go(-1)']>重新上传</a>]</font></div>"
case 3:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件太大且格式不对 [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
end select
response.write str
else
response.write "<script language=""javascript"">parent.form2.pic.value='"&Uprequest.SavePath&Uprequest.Form("file")&"';"
response.write "</script>"
response.write "</script>"
size=Uprequest.Form("file_size")
showsize=size & " Byte"
if size>1024 then
size=(size\1024)
showsize=size & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
response.write "<script language=""javascript"">parent.form2.url.value='"&showsize&"';"
response.write "</script>"
response.write "<div style=""padding-top:5px;padding-bottom:5px;""> <font color=red>文件上传成功</font> [<a href='javascript:history.go(-1)'>重新上传</a>]</div>"
end if
Set Uprequest=nothing
end if
response.write "<form name=form action=?action=pic&submit=pic method=post enctype=multipart/form-data>"
response.write "<input type=file name=file class='tx' size='20'> "
response.write "<input type=submit name=submit value=上传 class=""tx1"">"
response.write "</form>"
end sub
%>
第一个文件:
<html>
<body>
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.asp" method=post>
<input type=file name=mefile><br>
<input type=submit name=okvalue="OK">
</form>
</center>
</body>
</html>
第二个:
<%
sub pic()
if Request.QueryString("submit")="pic" then
uploadpath="image/face/"
uploadsize="2048"
uploadtype="jpg/gif/png/bmp"
Set Uprequest=new UpLoadClass
Uprequest.SavePath=uploadpath
Uprequest.MaxSize=uploadsize*1024
Uprequest.FileType=uploadtype
AutoSave=true
Uprequest.open
if Uprequest.form("file_Err")<>0 then
select case Uprequest.form("file_Err")
case 1:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件超过"&uploadsize&"k [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
case 2:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件格式不对 [<a href='javascript:history.go(-1)']>重新上传</a>]</font></div>"
case 3:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件太大且格式不对 [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
end select
response.write str
else
response.write "<script language=""javascript"">parent.form2.pic.value='"&Uprequest.SavePath&Uprequest.Form("file")&"';"
response.write "</script>"
response.write "</script>"
size=Uprequest.Form("file_size")
showsize=size & " Byte"
if size>1024 then
size=(size\1024)
showsize=size & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
response.write "<script language=""javascript"">parent.form2.url.value='"&showsize&"';"
response.write "</script>"
response.write "<div style=""padding-top:5px;padding-bottom:5px;""> <font color=red>文件上传成功</font> [<a href='javascript:history.go(-1)'>重新上传</a>]</div>"
end if
Set Uprequest=nothing
end if
response.write "<form name=form action=?action=pic&submit=pic method=post enctype=multipart/form-data>"
response.write "<input type=file name=file class='tx' size='20'> "
response.write "<input type=submit name=submit value=上传 class=""tx1"">"
response.write "</form>"
end sub
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询