Y
Yan Roosens
Hi all,
I try to download a mdb file. If I simply display a link to the file,
the right-click/Save Target As doesn't work.
I couild rename the mdb file into a zip file, I think the download would
work, but the user would have to rename the zip file into a mdb file,
and I try to avoid this.
Here is the code I have so far:
<%
Response.ContentType = "text/plain"
Response.AddHeader "Content-Transfer-Encoding", "binary;"
Response.AddHeader "Content-Disposition", "attachment;
filename=backup.mdb;"
thepath = server.mappath("/") & "\test\backup.mdb"
Set fsob = Server.CreateObject("Scripting.FileSystemObject")
set thefile = fsob.OpenTextFile(thepath)
response.BinaryWrite(thefile.ReadAll)
set fsob = Nothing
set thefile = Nothing
%>
The file is downloaded and saved on the local HD, but it is corrupted
and I can't open it with Access.
The mdb file on the server is 2,7 Mb and the locally saved file is 5,3
Mb.
I don't know exactly where is the problem. In the ContentType, in the
Encoding?
Or maybe the problem is in the OpenTextFile? Not the right way to open a
mdb file?
Does anybody know how to fix this code?
TIA
Yan
I try to download a mdb file. If I simply display a link to the file,
the right-click/Save Target As doesn't work.
I couild rename the mdb file into a zip file, I think the download would
work, but the user would have to rename the zip file into a mdb file,
and I try to avoid this.
Here is the code I have so far:
<%
Response.ContentType = "text/plain"
Response.AddHeader "Content-Transfer-Encoding", "binary;"
Response.AddHeader "Content-Disposition", "attachment;
filename=backup.mdb;"
thepath = server.mappath("/") & "\test\backup.mdb"
Set fsob = Server.CreateObject("Scripting.FileSystemObject")
set thefile = fsob.OpenTextFile(thepath)
response.BinaryWrite(thefile.ReadAll)
set fsob = Nothing
set thefile = Nothing
%>
The file is downloaded and saved on the local HD, but it is corrupted
and I can't open it with Access.
The mdb file on the server is 2,7 Mb and the locally saved file is 5,3
Mb.
I don't know exactly where is the problem. In the ContentType, in the
Encoding?
Or maybe the problem is in the OpenTextFile? Not the right way to open a
mdb file?
Does anybody know how to fix this code?
TIA
Yan