aspupload上传文件重命名的两种方法

方法一:
Set Upload = Server.CreateObject("Persits.Upload")

' Prevent overwriting
Upload.OverwriteFiles = False

' We use memory uploads, so limit file size
Upload.SetMaxSize 1000000, true

' Save to memory
Upload.Save

' Use session ID as the new file name
NewName = Session.SessionID

For Each File in Upload.Files
File.SaveAs "c:\upload\" & NewName & File.ext
Response.Write "New name: " & File.FileName & "<BR>"
Next


方法二:
Set Upload = Server.CreateObject("Persits.Upload")

' Prevent overwriting
Upload.OverwriteFiles = False

' Save to disk
Upload.Save "c:\upload"

' Use session ID as the new file name
NewName = Session.SessionID

For Each File in Upload.Files
File.Copy "c:\upload\" & NewName & File.ext
File.Delete
Response.Write "New name: " & NewName & File.ext & "<BR>"
Next


评论: 1 | 引用: 0 | 查看次数: 6849
发表评论
登录后再发表评论!