佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > aspupload文件重命名及上傳進(jìn)度條的解決方法附代碼第1/2頁

aspupload文件重命名及上傳進(jìn)度條的解決方法附代碼第1/2頁

熱門標(biāo)簽:服務(wù)器配置 電子圍欄 Mysql連接數(shù)設(shè)置 科大訊飛語音識別系統(tǒng) 銀行業(yè)務(wù) Linux服務(wù)器 阿里云 團(tuán)購網(wǎng)站
發(fā)現(xiàn)還沒有aspupload這個(gè)組件的,這兩樣功能的解決方案,現(xiàn)把我的改進(jìn)方案寫在這里!謝謝 
關(guān)于aspupload上傳組件,文件重命名,進(jìn)度條的問題解決方案! 
共用到4個(gè)文件,分別是1.asp,2.asp,bar.asp,framebar.asp 
運(yùn)行第一個(gè)文件:1.asp,執(zhí)行上傳操作! 
復(fù)制代碼 代碼如下:

%
'''進(jìn)度條
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()
//加載進(jìn)度條

  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";//客戶端,檢測文件后綴名,省得上傳完成后,才報(bào)文件類型錯(cuò)誤!
    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
復(fù)制代碼 代碼如下:

%

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 保存到內(nèi)存
Upload.Save

If Err.Number = 8 Then
   Response.Write "文件大于1G"
End If 


'為使文件不重名,用系統(tǒng)時(shí)間+隨機(jī)數(shù),作為文件名
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,".",""))
                '服務(wù)器端判斷文件類型,動(dòng)網(wǎng)論壇的判斷方式
                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 

%> 
%
'服務(wù)器端判斷文件類型,動(dòng)網(wǎng)論壇的判斷方式
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,ASPJPEG實(shí)現(xiàn)圖片上傳自動(dòng)生成縮略圖及加上水印
  • aspupload 3.0 下載與使用集錦

標(biāo)簽:萍鄉(xiāng) 江蘇 大理 棗莊 衡水 衢州 蚌埠 廣元

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《aspupload文件重命名及上傳進(jìn)度條的解決方法附代碼第1/2頁》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    黑龙江省| 盐边县| 莱芜市| 乌兰察布市| 棋牌| 东海县| 彭州市| 呈贡县| 包头市| 莆田市| 泰顺县| 阳城县| 永胜县| 仲巴县| 安仁县| 怀安县| 德兴市| 托克托县| 阳江市| 鲜城| 招远市| 申扎县| 贡嘎县| 溧阳市| 鄯善县| 铜鼓县| 乌兰察布市| 灌阳县| 保靖县| 滁州市| 乃东县| 西乡县| 文昌市| 社会| 通榆县| 崇仁县| 政和县| 余庆县| 瓮安县| 佛学| 烟台市|