国产精品免费虐久久久久影院_亚洲日韩av一区二区三区久久_一个人的视频全免费在线观看www_国产黄色福利青草精品在线_久久机热国产精品免费观看_日本一二三区免费在线_好亚洲亚洲人成综合网站图片_亚洲中文字幕超碰无码资源_日本人天天干夜夜操b视频_动漫女扒开腿爆乳无遮挡gif

FASTGPT 喵言AI 續(xù)費(fèi)系統(tǒng)

如何使用AspUpload組件上傳文件

使用AspUpload組件上傳文件,使用范例代碼如下:

AspUpload組件上傳測(cè)試


 

 
 
其他表單項(xiàng)

 


<%
if request("act") = "upload" then

 AllowExt = "jpg,png,gif,zip,rar,sql,txt,bak"
 On Error Resume Next

 ' 新建AspUpload對(duì)象
 Set Upload = Server.CreateObject("Persits.Upload")

 ' 限制文件大小
 Upload.SetMaxSize 4194304, True

 ' 上傳路徑--當(dāng)前目錄下的test目錄
 uploadDir = Server.MapPath("test")

 ' 嘗試創(chuàng)建路徑文件夾,true表示忽略目錄已存在錯(cuò)誤
 Upload.CreateDirectory uploadDir, true

 ' 先上傳文件至服務(wù)器內(nèi)存
 Count = Upload.Save()

 ' 檢測(cè)上傳錯(cuò)誤
 If Err.Number = 8 Then
  Response.Write chinese2unicode("錯(cuò)誤: 文件過(guò)大!")
  Response.end
 Else
  If Err <> 0 Then
   response.write chinese2unicode("發(fā)生錯(cuò)誤:")
   response.write chinese2unicode(Err.Description)
   response.end
  End If
 End If

 'Response.Write chinese2unicode("共 " & Count & " 個(gè)文件") & "

"

 ' 指定一個(gè)上傳的表單文件
 Set File = Upload.Files("file1")
 If Not File Is Nothing Then
  ' 獲取原本文件名
  Filename = File.Filename
  ' 獲取文件擴(kuò)展名
  Fileext = File.Ext

  ' 檢測(cè)文件格式是否合格
  ChkStr = ","&Lcase(AllowExt)&","
  If Instr(ChkStr,","&right(Fileext,3)&",") <= 0 Then
   Response.Write chinese2unicode("錯(cuò)誤: 文件類型不正確!")
   response.write "
"
   response.write chinese2unicode("只允許:"&AllowExt)
   ' 刪除內(nèi)存中的臨時(shí)文件,以釋放內(nèi)存或硬盤空間(還可用Copy、Move兩個(gè)指令)
   File.Delete
  ' 檢測(cè)是否存在文件
  elseif Upload.FileExists(uploadDir & "" & Filename) Then
   File.SaveAs uploadDir & "" & Filename
   Response.Write chinese2unicode("已覆蓋存在相同文件名的文件: ") & File.Path
  ' 保存文件
  else
   File.SaveAs uploadDir & "" & Filename
   Response.Write chinese2unicode("文件已保存到: ") & File.Path
  end If
 Else
  Response.Write chinese2unicode("錯(cuò)誤: 您并沒(méi)有選擇文件!")
 End If

 Response.Write "

"

 '' 批量上傳文件,去掉注釋即可用。
 For Each File in Upload.Files
   'File.SaveAs uploadDir & "" & File.FileName
   'Response.Write chinese2unicode("文件已保存到: ") & File.Path & "
"
 Next


'Response.Write "

Files:
"
For Each File in Upload.Files
 'Response.Write File.Name & "= " & File.Path & " (" & File.Size &" bytes)
"
Next

'' 列出其他表單內(nèi)容(必須執(zhí)行Upload.Save()后才有效)
For Each Item in Upload.Form
 Response.Write Item.Name & " = " & Item.Value & "
"
Next

'列出指定的表單內(nèi)容
Response.Write "
"&chinese2unicode("列出指定內(nèi)容uploadText:"&Upload.Form("uploadText").value)

 

end if

 

' gb2312轉(zhuǎn)unicode,解決中文亂碼問(wèn)題
function chinese2unicode(Str)
 dim i
 dim Str_one
 dim Str_unicode
 for i=1 to len(Str)
  Str_one=Mid(Str,i,1)
  Str_unicode=Str_unicode&chr(38)
  Str_unicode=Str_unicode&chr(35)
  Str_unicode=Str_unicode&chr(120)
  Str_unicode=Str_unicode& Hex(ascw(Str_one))
  Str_unicode=Str_unicode&chr(59)
 next
 Response.Write Str_unicode
end function    
%>