aspupload文件重命名及上傳進度條的解決方法附代碼第1/2頁
2024-05-04 11:01:19
供稿:網友
發現還沒有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>