aspupload文件重命名及上传进度条的解决方法附代(2)
</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)
内容版权声明:除非注明,否则皆为本站原创文章。