|
HI all
I have a database with info on files that are stored in a folder on my site. When you click the file ID, the file is streamed to the user.
I have noticed that when the files are not in english (in my example: hebrew), as in: hebrew_name.doc The file does not stream properly to the user, and it seems as though the browser cannot locate the file. In fact, even giving the full path: http://www.site.com/secretPath/hebrew_name.doc - www.site.com/secretPath/hebrew_name.doc , doesn’t work as it does with 'regular' files.
Any idea how I can do this? I've also tried using server.HTMLencode and server.URLencode on the file name, but zilch.
Anything? Thanks! Kn
code follows - - - - - - - - - - - - - - - - - - - - - - <%@LANGUAGE="VBSCRIPT" CODEPAGE="1255" LCID = "2057" %> <!--#include virtual="/includes/common.asp" --> <!--#include virtual="/admn/files/config.asp"--> <!--#include virtual="/admn/files/aspmkrfn.asp"--> <% strID = Request.Querystring("ID") If strID = "" Or IsNull(strID) Then strID = Request.Form("id") If strID = "" Or IsNull(strID) Then Response.Redirect "ChinuchDB.asp"
Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str strsql = "SELECT * FROM [tblFiles] WHERE [file_ID]=" & strID Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn, 1, 2 If rs.Eof Then Respon se.Clear rs.Clo se Set rs = Nothing conn.c lose set conn = nothing Respon se.Redirect "ChinuchDB.asp" Else rs.Mov eFirst
' Get the field contents x_file _ID = rs("file_ID") x_file _name = rs("file_name") x_file _size = rs("file_size") x_file _orig_name = rs("file_orig_name") x_file _uploaded = rs("file_uploaded") x_file _status = rs("file_status") x_file _downloaded = rs("file_downloaded") rs("fi le_downloaded") = x_file_downloaded +1
rs.upd ate rs.Clo se Set rs = Nothing
End If 'now find mime type: SQLmime = "SELECT * FROM tblMime WHERE extension = '" & right(x_file_name,3) & "'" set rsMime = Server.CreateObject("ADODB.Recordset") rsMime.open SQLmime, conn if rsMime.eof then SQLmim e = "SELECT * FROM tblMime WHERE extension = '" & right(x_file_name,4) & "'" rsMime .requery end if strMimeType = rsMime("MimeType") rsMime.close set rsMime = nothing conn.close set conn = nothing
if x_file_status = "off" then response.Redirect("ChinuchDB.asp")
'strFileName = x_file_name 'right(x_file_name, len(x_file_name)-9) strFileName = left(x_file_name, len(x_file_name)-4) strOrigFileName = left(x_file_orig_name, len(x_file_orig_name)-4) strFileExtension = right(x_file_name, 3) intDocSize = clng(x_file_size)*1024 dtModified = cdate(x_file_uploaded) strSecretPath = strFileUploadPath & server.URLEncode(strFileName) & "." & strFileExtension bDownload = true 'to force the "Save As" box (IE 5.0 has bug though)
Response.ContentType = strMimeType '"application/octet-stream" 'Response.ContentType = "application/octet-stream"
' Send file name and disposition (default/inline vs. attachment) If bDownload Then ' attachment mode to force the "Save As" box (IE 5.0 has bug though) ***str OrigFileName Response.AddHeader "Content-Disposition", "attachment;filename=""" & server.URLEncode(x_file_ID) & "." & strFileExtension & """" Else ' let browser decide Response.AddHeader "Content-Disposition", "filename=""" & server.URLEncode(x_file_ID) & "." & strFileExtension & """" End If ' Send modification time Dim hh, mm, ss hh = Hour(dtModified) If hh < 10 Then hh = "0" & hh End If mm = Minute(dtModified) If mm < 10 Then mm = "0" & mm End If ss = Second(dtModified) If ss < 10 Then ss = "0" & ss End If
Response.AddHeader "Last-Modified", WeekDayName(WeekDay(dtModified),True) & ", " & Day(dtModified) & " " & MonthName(Month(d
|