如题,动网的哪个asp论坛,的下载比现在的科讯下载要方便,他下载的文件名还是保留了上传时的文件名,但在服务器上的文件名还是案日期生成的,不知科讯是否可以学习一下?
因为在一些网站,下载的文件都不是很大,但如果在下载的时候改名是很不方便的,如要能在下载的时候引用上传时的文件名的话,这样对客户是个很不错的体验!!!!!
下面是动网论坛下载的代码文件
-
End If
- If Dvbbs.Forum_Setting(76)="" Or Dvbbs.Forum_Setting(76)="0" Then Dvbbs.Forum_Setting(76)="UploadFile/"
- If right(Dvbbs.Forum_Setting(76),1)<>"/" Then Dvbbs.Forum_Setting(76)=Dvbbs.Forum_Setting(76)&"/"
- Dim uploadpath,filename
- uploadpath=Dvbbs.Forum_Setting(76)
- Set Rs=Dvbbs.Execute("Select * From dv_upfile Where F_id="&downid)
- If Rs.Eof And Rs.Bof Then
- Dvbbs.AddErrCode(32)
- ElseIf Dvbbs.BoardID <> Int(Rs("F_BoardID")) Then
- Dvbbs.AddErrCode(32) Rem 判断版面来源
- Else
- If DownUserQStr <> "" Then
- UserInfo.setAttribute "usermoney", (DownUserMoney - BoardUserLimited(9))
- UserInfo.setAttribute "userwealth", (DownUserWealth - BoardUserLimited(10))
- UserInfo.setAttribute "userep", (DownUserEp - BoardUserLimited(11))
- Dvbbs.Execute("Update Dv_User Set "&Right(DownUserQStr,Len(DownUserQStr)-1)&" Where UserID="&Dvbbs.UserID)
- End If
- If DownUserQStr <> "" Then Dvbbs.Execute("Update Dv_User Set "&Right(UploadUserQStr,Len(UploadUserQStr)-1)&" Where UserID="&Rs("F_UserID")&"")
- Dvbbs.Execute("Update dv_upfile Set F_DownNum=F_DownNum+1 Where F_ID="&DownID)
- If Dvbbs.Forum_Setting(75)="0" Then
- If Rs("F_OldName") = "" Or IsNull(Rs("F_OldName")) Then
- Response.Redirect uploadpath&rs("F_filename")
- Else
- downloadFile Server.MapPath(uploadpath&rs("F_filename")),Rs("F_OldName")
- End If
- Else
- filename=Replace(rs("F_filename"),"..","")&""
- If Request.ServerVariables("HTTP_REFERER")="" Or InStr(Request.ServerVariables("HTTP_REFERER"),Request.ServerVariables("SERVER_NAME"))=0 Or filename="" Then
- Response.Redirect "index.asp"
- Else
- downloadFile Server.MapPath(Dvbbs.Forum_Setting(76)&filename),Rs("F_OldName")
- End If
- End If
- End If
- Rs.close
- Set Rs=Nothing
- Dvbbs.ShowErr()
- Dvbbs.PageEnd()
Sub downloadFile(strFile,FileOldName)
- On error resume next
- Server.ScriptTimeOut=999999
- Dim S,fso,f,intFilelength,strFilename,DownFileName
- strFilename = strFile
- Response.Clear
- Set s = Dvbbs.iCreateObject("ADODB.Stream")
- s.Open
- s.Type = 1
- Set fso = Dvbbs.iCreateObject("Scripting.FileSystemObject")
- If Not fso.FileExists(strFilename) Then
- Response.Write("<h1>错误: </h1><br>系统找不到指定文件")
- Exit Sub
- End If
- Set f = fso.GetFile(strFilename)
- intFilelength = f.size
- s.LoadFromFile(strFilename)
- If err Then
- Response.Write("<h1>错误: </h1>" & err.Description & "<p>")
- Response.End
- End If
- Set fso=Nothing
- Dim Data
- Data=s.Read
- s.Close
- Set s=Nothing
- If FileOldName="" Or IsNull(FileOldName) Then DownFileName=f.name Else DownFileName=FileOldName
- If Response.IsClientConnected Then
- Response.AddHeader "Content-Disposition", "attachment; filename=" & DownFileName
- Response.AddHeader "Content-Length", intFilelength
- Response.CharSet = "UTF-8"
- Response.ContentType = "application/octet-stream"
- Response.BinaryWrite Data
- Response.Flush
- End If
- End Sub
- %>
这是动网的一个附件提交过程
他保存在服务器的文件名还是以时间来重命名的
这里他保存的文件名下载时还是不变的!
我知道这样做对服务器负荷可能会加大,但是现在论坛的上传文件都不是很大,很少有论坛可以上传半M以上的文件,这里我强烈建议科讯改进一下!
这里我看了一下动网论坛的代码,他也只是在上传的时候把,上传文件名写入了数库dv_upfile表的F_OldName字段
下载的时候再读取数据库重写了文件名、