Dim sServerDir sServerDir = Server.MapPath( ConfigUserFilesPath ) If ( Right( sServerDir, 1 ) > "\" ) Then sServerDir = sServerDir "\" End If
把它下面的这两行
Dim oFSO Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" ) 用下面这一段代码来替换
dim arrPath,strTmpPath,intRow strTmpPath = "" arrPath = Split(sServerDir, "\") Dim oFSO Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" ) for intRow = 0 to Ubound(arrPath) strTmpPath = strTmpPath arrPath(intRow) "\" if oFSO.folderExists(strTmpPath)=false then oFSO.CreateFolder(strTmpPath) end if next 用这段代码就可以生成你想要的文件夹了,在上传的时候自动生成。
在刚才那一段代码的下面紧接着就是 ' Get the uploaded file name. sFileName = oUploader.File( "NewFile" ).Name 看清楚了,这个就是文件名啦,我们来把它改掉,当然得有个生成文件名的函数才行,改成下面这样
'//取得一个不重复的序号 Public Function GetNewID() dim ranNum dim dtNow randomize dtNow=Now() ranNum=int(90000*rnd)+10000 GetNewID=year(dtNow) right("0" month(dtNow),2) right("0" day(dtNow),2) right("0" hour(dtNow),2) right("0" minute(dtNow),2) right("0" second(dtNow),2) ranNum End Function
' Get the uploaded file name. sFileName = GetNewID() "." split(oUploader.File( "NewFile" ).Name,".")(1)