Aspupload组件使用实例代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

<%@EnableSessionState=False%>
<%
Response.Expires = -1
PID = Request("PID")
TimeO = Request("to")
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
format = "

正在上传,请耐心等待...

%T%t%B3%T 速度:(%S/秒) 估计剩余时间:%R %r%U / %V(%P)%l%t"
bar_content = UploadProgress.FormatProgress(PID, TimeO, "#00007F", format)
If "" = bar_content Then
%>


Upload Finished





<%
Else ' Not finished yet
%>


Response.Write "?to=" & TimeO & "&PID=" & PID %>">
Uploading Files...



<% = bar_content %>


<% End If %>


fileconfig.asp

<%
Dim UploadFilePath,UploadLimitSize,NotAllowfileext,BrowerFilePath
UploadFilePath = year(now)&"_"&month(now)&"_"&day(now)&"/"
'文件上传路径

BrowerFilePath = "/"

UploadLimitSize = 1024*50 '50M
'最大上传文件大小,单位为K

NotAllowfileext = "asp|cer|cdx|asa|htw|ida|idq|shtm|shtml|stm|printer|cgi|php|php4|cfm|aspx"
'不可以上传的文件类型

function CanUpload(Fileurl)
Fileurl = lcase("|"& Mid(Fileurl, InstrRev(Fileurl, ".") + 1)& "|")
NotAllowfileextstr = "|"&NotAllowfileext&"|"
if instr(NotAllowfileextstr,Fileurl)>0 then
CanUpload = false
else
CanUpload = true
end if
end function

Function CreateFolder(Filepath)
Dim fso, f
on error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(Filepath) then
Set f = fso.CreateFolder(Filepath)
set f = Nothing
end if
set fso = Nothing
End Function
%>


framebar.asp

<%@EnableSessionState=False%>
<% Response.Expires = -1 %>
正在上传............












uploadfile.asp








Upload



<%
On Error Resume Next
Server.ScriptTimeOut=999999
if request("act")="upload" then
dim folder,savepath
savepath=Server.MapPath(UploadFilePath)
CreateFolder(savepath)
Set Upload=Server.CreateObject("Persits.Upload")
Upload.SetMaxSize UploadLimitSize*1024, True
Upload.OverwriteFiles = false
if Request.QueryString("PID") = "" then
Upload.ProgressID="010D60EB00C5AA4B"
else
Upload.ProgressID=Request.QueryString("PID")
end if
Count=Upload.Save(savepath)
If Err.Number <> 0 Then
Response.Write "
出现错误: " & Err.Number & "、" & Err.Description &"重新上传
"
End If
If Err.Number = 8 Then
Response.Write "
你上传的文件超过限制("& UploadLimitSize/1024 &"M)重新上传
"
response.end
end if
dim inputname
dim size,rs_upfile
For Each File in Upload.Files
if not CanUpload(File.ext) then
File.Delete
response.write "
"&file.filename &"("& file.size &") 格式不正确!重新上传
"
else
dim NewName
NewName = year(now) & "-" & month(now) & "-" & day(now) & "-" & hour(now) & "-" & minute(now) & "-" & second(now) & File.ext
File.Move savepath & "\" & NewName
response.write "
上传成功"%>重新上传
<%
end if
next
else
%>
<%
dim SPid,PID,barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
SPid = UploadProgress.CreateProgressID()
PID = "PID=" & SPid
barref = "framebar.asp?to=10&" & PID
%>



<%end if%>



相关文档
最新文档