473,511 Members | 15,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download file with [1] at the end of the file name

Hi,
I've the code bellow who give me a file to download.
The files are sored in a folder. The filename is the id of the data stored
in a table.
The name of the file at the download time will be the one stored in the
table.
The problem is that if the file name in the table is toto.doc the browser
propose me to save it at toto.doc[1]
How can I get rid of the [1]
The file can be of any tipe.

<!--#include file="header.inc"-->
<%
dim fileId
dim fileName
dim path
dim sql
dim rs
dim objFSO
dim objFile
dim objStream

fileId = Request.QueryString("fileId")

sql = "select * from file where id_file = " & fileId
set rs = Server.CreateObject("ADODB.Recordset")
Call rs.Open(sql, conn, adOpenStatic, adLockReadOnly)
fileName = rs("fileName")
path = Server.MapPath("file") & "\"

set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(path & fileId) Then
Set objFile = objFSO.GetFile(path & fileId)
' write header
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=" &
Server.URLEncode(fileName)
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
' get the data
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1 'adTypeBinary
Response.CharSet = "UTF-8"
objStream.LoadFromFile(path & fileId)
Response.BinaryWrite(objStream.Read)
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
else
%>
<html>
<body>
<h1>File not found</h1>
</body>
</html>
<%
end if
set objFSO = Nothing
%>


Jul 19 '05 #1
0 1140

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3223
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
0
2150
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
0
3995
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
1
47353
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.