展开全部
用无组件上传吗?给你两个页面用一用
先保存以下这段为“1.asp”:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script language="javascript">
function upup()
{
var returnTarget=window.showModalDialog("2.asp?action=up","","dialogWidth:300px;dialogHeight:150px;scroll:no;status:no");
if(returnTarget!=undefined && returnTarget.length>1)
{
proform.imgtxt.value=returnTarget;
}
return false;
}
</script>
<body>
<form action="" method="get" name="proform" id="proform">
<label>
<input name="imgtxt" type="text" id="imgtxt">
</label>
<label>
<input type="button" name="Submit" value="浏览" onClick="upup()">
</label>
</form>
</body>
</html>
再保存下面这段为“2.asp”:
<!--#include file="Upload_inc.asp"-->
<html>
<head>
<title>上传\导入</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function exit(address){
window.returnValue=address;
window.close();
}
</script>
</head>
<base target="_self">
<%
dim upload,file
if request("action")="add" then
call add()
else
call main()
end if
sub add()
dim upload,file
set upload=new upload_5xsoft
set file=upload.file("ttt")
if file.fileSize<1 then
response.write"<script language=javascript>alert('您没有选择图片。~~~\n\n-----请点击浏览按钮,从弹出的窗口中选择要上传的图片。\n\n-----然后点击上传按钮就可以把图片上传了...\n\n-----不过要注意图片的格式哦~~~');history.back()</script>"
response.end
end if
if file.fileSize<10 or file.fileSize>1000*1024 then
response.write "错误:上传的图片大小超过了限制! <a href='javascript:history.go(-1)'>退回上一步</a>"
response.end
end if
upfilename = split(file.FileName,".")
upfileext = upfilename(ubound(upfilename))
if upfileext<>"jpg" and upfileext<>"jpeg" and upfileext<>"gif" and upfileext<>"JPG" and upfileext<>"JPEG" and upfileext<>"GIF"then
response.write "错误:上传的文件格式不对! <a href='javascript:history.go(-1)'>退回上一步</a>"
response.end
end if
ufp="UP_"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&upfilename(ubound(upfilename))
file.saveas Server.mappath("UploadFile/"&ufp)
response.write "<script>window.returnValue='"&ufp&"';window.close();</script>"
set file=nothing
set upload=nothing
end sub
sub main()%>
<form name="form1" method="post" action="?action=add" enctype="multipart/form-data">
<input name="ttt" type="file">
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
<%end sub%>
</html>
试一试吧,我都用这个
下载的话,就更简单了,直接用超级链接,链接到你的文件所在位置就行了。
先保存以下这段为“1.asp”:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script language="javascript">
function upup()
{
var returnTarget=window.showModalDialog("2.asp?action=up","","dialogWidth:300px;dialogHeight:150px;scroll:no;status:no");
if(returnTarget!=undefined && returnTarget.length>1)
{
proform.imgtxt.value=returnTarget;
}
return false;
}
</script>
<body>
<form action="" method="get" name="proform" id="proform">
<label>
<input name="imgtxt" type="text" id="imgtxt">
</label>
<label>
<input type="button" name="Submit" value="浏览" onClick="upup()">
</label>
</form>
</body>
</html>
再保存下面这段为“2.asp”:
<!--#include file="Upload_inc.asp"-->
<html>
<head>
<title>上传\导入</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function exit(address){
window.returnValue=address;
window.close();
}
</script>
</head>
<base target="_self">
<%
dim upload,file
if request("action")="add" then
call add()
else
call main()
end if
sub add()
dim upload,file
set upload=new upload_5xsoft
set file=upload.file("ttt")
if file.fileSize<1 then
response.write"<script language=javascript>alert('您没有选择图片。~~~\n\n-----请点击浏览按钮,从弹出的窗口中选择要上传的图片。\n\n-----然后点击上传按钮就可以把图片上传了...\n\n-----不过要注意图片的格式哦~~~');history.back()</script>"
response.end
end if
if file.fileSize<10 or file.fileSize>1000*1024 then
response.write "错误:上传的图片大小超过了限制! <a href='javascript:history.go(-1)'>退回上一步</a>"
response.end
end if
upfilename = split(file.FileName,".")
upfileext = upfilename(ubound(upfilename))
if upfileext<>"jpg" and upfileext<>"jpeg" and upfileext<>"gif" and upfileext<>"JPG" and upfileext<>"JPEG" and upfileext<>"GIF"then
response.write "错误:上传的文件格式不对! <a href='javascript:history.go(-1)'>退回上一步</a>"
response.end
end if
ufp="UP_"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&"."&upfilename(ubound(upfilename))
file.saveas Server.mappath("UploadFile/"&ufp)
response.write "<script>window.returnValue='"&ufp&"';window.close();</script>"
set file=nothing
set upload=nothing
end sub
sub main()%>
<form name="form1" method="post" action="?action=add" enctype="multipart/form-data">
<input name="ttt" type="file">
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
<%end sub%>
</html>
试一试吧,我都用这个
下载的话,就更简单了,直接用超级链接,链接到你的文件所在位置就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询