木子屋 Dnawo's BLOG

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

👤 dnawo 📅 2007-06-08 👁 7461 👍 0 💬 0 🔄 fansart.com 📂 Web编程
方法一:
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

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 你的成功在于你每天养成的习惯 下一篇 → 关于版权声明的写法