Home All Groups Group Topic Archive Search About

Downloading files from ASP Page



Author
18 Sep 2006 12:21 PM
JP SIngh
Can someone please help me with a file download query. I have the following
code which works fine.

The only change I want to make is in the line objStream.loadfromfile
server.mappath("/images/"&strFile)

It is using a folder on the IIS Server to store the files.

Does anyone know how I can change the path speficied in the LoadFromFile to
a UNC path name i.e. \\myserver\images

This is an internal application and the server hosting the application is
too small to hold the amount of data hence a new server has been setup to
store files but I am unable to download it from the server.


<body>
Here is the code:
<p>Make your links like this
<a href="download.asp?doc=document1.doc"> Word Document</p>
</body>

Code for download.asp

<%
strFile=request.querystring("doc")
const adTypeBinary = 1
response.clear
response.addheader "content-disposition","attachment; filename=" &strFile
set objStream = server.createObject("adodb.stream")
objStream.type = adTypeBinary
objStream.open
'This is signifying that the doc are in a folder called WordDocs
objStream.loadfromfile server.mappath("/images/"&strFile)
response.binarywrite objStream.Read
objStream.close: set objStream = nothing
%>

Author
18 Sep 2006 2:09 PM
mike.biang
JP,
If the files will always be located on the UNC share \\myserver\images,
you can simply hardcode the path in the loadfromfile call.

For example:
objStream.loadfromfile "\\myserver\images\" & strFile


If you know the full path to the file, there is no need for the
Server.MapPath call.

Mike Biang
Cramer Development
mike.bi***@gmail.com

JP SIngh wrote:
Show quote
> Can someone please help me with a file download query. I have the following
> code which works fine.
>
> The only change I want to make is in the line objStream.loadfromfile
> server.mappath("/images/"&strFile)
>
> It is using a folder on the IIS Server to store the files.
>
> Does anyone know how I can change the path speficied in the LoadFromFile to
> a UNC path name i.e. \\myserver\images
>
> This is an internal application and the server hosting the application is
> too small to hold the amount of data hence a new server has been setup to
> store files but I am unable to download it from the server.
>
>
> <body>
> Here is the code:
> <p>Make your links like this
> <a href="download.asp?doc=document1.doc"> Word Document</p>
> </body>
>
> Code for download.asp
>
> <%
> strFile=request.querystring("doc")
> const adTypeBinary = 1
> response.clear
> response.addheader "content-disposition","attachment; filename=" &strFile
> set objStream = server.createObject("adodb.stream")
> objStream.type = adTypeBinary
> objStream.open
> 'This is signifying that the doc are in a folder called WordDocs
> objStream.loadfromfile server.mappath("/images/"&strFile)
> response.binarywrite objStream.Read
> objStream.close: set objStream = nothing
> %>
Author
18 Sep 2006 2:24 PM
Jason Simmons
if all this is is a link to download a file, why are you doing all the
unnecessray scripting?
a simple HTML HREF tag would work fine


Show quote
"JP SIngh" <n***@none.com> wrote in message
news:uQcdWzx2GHA.4924@TK2MSFTNGP05.phx.gbl...
> Can someone please help me with a file download query. I have the
> following code which works fine.
>
> The only change I want to make is in the line objStream.loadfromfile
> server.mappath("/images/"&strFile)
>
> It is using a folder on the IIS Server to store the files.
>
> Does anyone know how I can change the path speficied in the LoadFromFile
> to a UNC path name i.e. \\myserver\images
>
> This is an internal application and the server hosting the application is
> too small to hold the amount of data hence a new server has been setup to
> store files but I am unable to download it from the server.
>
>
> <body>
> Here is the code:
> <p>Make your links like this
> <a href="download.asp?doc=document1.doc"> Word Document</p>
> </body>
>
> Code for download.asp
>
> <%
> strFile=request.querystring("doc")
> const adTypeBinary = 1
> response.clear
> response.addheader "content-disposition","attachment; filename=" &strFile
> set objStream = server.createObject("adodb.stream")
> objStream.type = adTypeBinary
> objStream.open
> 'This is signifying that the doc are in a folder called WordDocs
> objStream.loadfromfile server.mappath("/images/"&strFile)
> response.binarywrite objStream.Read
> objStream.close: set objStream = nothing
> %>
>
Author
13 Oct 2006 4:28 PM
John
Probably because he wants the Open|Save dialog box to pop-up rather than allowing the browser to automatically open the file... I am trying to do the same thing...

AddThis Social Bookmark Button