发现还没有aspupload这个组件的,这两样功能的解决方案,现把我的改进方案写在这里!谢谢
关于aspupload上传组件,文件重命名,进度条的问题解决方案!
共用到4个文件,分别是1.asp,2.asp,bar.asp,framebar.asp
运行第一个文件:1.asp,执行上传操作!
复制代码 代码如下:
<%
'''进度条
dim SPid,PID,barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
SPid = UploadProgress.CreateProgressID()
PID = "PID=" & SPid
barref = "framebar.asp?to=10&" & PID
%>
<SCRIPT language="javascript">
<!--
function ShowProgress()
//加载进度条
{
strAppVersion = navigator.appVersion;
if (document.upfile.filename.value != "")
{
if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
{
winstyle = "dialogWidth=375px; dialogHeight:175px; center:yes;status:no";
window.showModelessDialog('<% = barref %>&b=IE',window,winstyle);
}
else
{
window.open('<% = barref %>&b=NN','','width=370,height=165', true);
}
}
return true;
}
function isPic(){
var temp;
var ExtList = ".jpg.gif.bmp.png.swf";//客户端,检测文件后缀名,省得上传完成后,才报文件类型错误!
var filename = upfile.filename.value;
var the_ext = filename.substr(filename.lastIndexOf(".")+1).toLowerCase();
if (ExtList.indexOf(the_ext)==-1){
alert("不是图片,请选择图片文件!");
return false;
}
return true;
}
//-->
</SCRIPT>
<html>
<head></head>
<body>
<form method="post"enctype="multipart/form-data"action="2.asp?<% = PID %>"name="upfile"OnSubmit="return ShowProgress();">
选择要上传的文件:<br>
<input type=file name="filename"><br>
<input type=submit value="上传" onclick="return isPic()">
</form>
</body>
</html>
2.asp
复制代码 代码如下:
<%
Set Upload = Server.CreateObject("Persits.Upload")
' Prevent overwriting
Upload.OverwriteFiles = False
' We use memory uploads, 文件大小限制 ,单位:b
Upload.SetMaxSize 1*1024*1024*1024, true
if Request.QueryString("PID") = "" then
Upload.ProgressID="010D60EB00C5AA4B"
else
Upload.ProgressID=Request.QueryString("PID")
end if
On Error Resume Next
' Save to memory 保存到内存
Upload.Save
If Err.Number = 8 Then
Response.Write "文件大于1G"
End If
'为使文件不重名,用系统时间+随机数,作为文件名
Dim ranNum
randomize
ranNum=int(999*rnd)
CreateName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
NewName = CreateName
'保存文件路径
articlepath = Server.MapPath("upload1")
For Each File in Upload.Files
FileExt=Lcase(replace(File.ext,".",""))
'服务器端判断文件类型,动网论坛的判断方式
If CheckFileExt(FileExt)=false then
Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
else
File.SaveAs articlepath & "/" & NewName & File.ext
Response.Write "New name: " & File.FileName & "<BR>"
End If
Next
%>
<%
'服务器端判断文件类型,动网论坛的判断方式
Private Function CheckFileExt(FileExt)
If FileExt="" or IsEmpty(FileExt) Then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="asp" or Lcase(FileExt)="asa" or Lcase(FileExt)="aspx" then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="gif" or Lcase(FileExt)="jpg" or Lcase(FileExt)="png" or Lcase(FileExt)="swf" or Lcase(FileExt)="bmp" then
CheckFileExt=true
Exit Function
Else
CheckFileExt=false
End If
End Function
%>
12下一页阅读全文
关于aspupload上传组件,文件重命名,进度条的问题解决方案!
共用到4个文件,分别是1.asp,2.asp,bar.asp,framebar.asp
运行第一个文件:1.asp,执行上传操作!
复制代码 代码如下:
<%
'''进度条
dim SPid,PID,barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
SPid = UploadProgress.CreateProgressID()
PID = "PID=" & SPid
barref = "framebar.asp?to=10&" & PID
%>
<SCRIPT language="javascript">
<!--
function ShowProgress()
//加载进度条
{
strAppVersion = navigator.appVersion;
if (document.upfile.filename.value != "")
{
if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
{
winstyle = "dialogWidth=375px; dialogHeight:175px; center:yes;status:no";
window.showModelessDialog('<% = barref %>&b=IE',window,winstyle);
}
else
{
window.open('<% = barref %>&b=NN','','width=370,height=165', true);
}
}
return true;
}
function isPic(){
var temp;
var ExtList = ".jpg.gif.bmp.png.swf";//客户端,检测文件后缀名,省得上传完成后,才报文件类型错误!
var filename = upfile.filename.value;
var the_ext = filename.substr(filename.lastIndexOf(".")+1).toLowerCase();
if (ExtList.indexOf(the_ext)==-1){
alert("不是图片,请选择图片文件!");
return false;
}
return true;
}
//-->
</SCRIPT>
<html>
<head></head>
<body>
<form method="post"enctype="multipart/form-data"action="2.asp?<% = PID %>"name="upfile"OnSubmit="return ShowProgress();">
选择要上传的文件:<br>
<input type=file name="filename"><br>
<input type=submit value="上传" onclick="return isPic()">
</form>
</body>
</html>
2.asp
复制代码 代码如下:
<%
Set Upload = Server.CreateObject("Persits.Upload")
' Prevent overwriting
Upload.OverwriteFiles = False
' We use memory uploads, 文件大小限制 ,单位:b
Upload.SetMaxSize 1*1024*1024*1024, true
if Request.QueryString("PID") = "" then
Upload.ProgressID="010D60EB00C5AA4B"
else
Upload.ProgressID=Request.QueryString("PID")
end if
On Error Resume Next
' Save to memory 保存到内存
Upload.Save
If Err.Number = 8 Then
Response.Write "文件大于1G"
End If
'为使文件不重名,用系统时间+随机数,作为文件名
Dim ranNum
randomize
ranNum=int(999*rnd)
CreateName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
NewName = CreateName
'保存文件路径
articlepath = Server.MapPath("upload1")
For Each File in Upload.Files
FileExt=Lcase(replace(File.ext,".",""))
'服务器端判断文件类型,动网论坛的判断方式
If CheckFileExt(FileExt)=false then
Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
else
File.SaveAs articlepath & "/" & NewName & File.ext
Response.Write "New name: " & File.FileName & "<BR>"
End If
Next
%>
<%
'服务器端判断文件类型,动网论坛的判断方式
Private Function CheckFileExt(FileExt)
If FileExt="" or IsEmpty(FileExt) Then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="asp" or Lcase(FileExt)="asa" or Lcase(FileExt)="aspx" then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="gif" or Lcase(FileExt)="jpg" or Lcase(FileExt)="png" or Lcase(FileExt)="swf" or Lcase(FileExt)="bmp" then
CheckFileExt=true
Exit Function
Else
CheckFileExt=false
End If
End Function
%>
12下一页阅读全文
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“aspupload文件重命名及上传进度条的解决方法附代码第1/2页”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。