472,802 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,802 software developers and data experts.

Downloading files from ASP Page

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
%>
Sep 18 '06 #1
3 4350
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
mi********@gmail.com

JP SIngh wrote:
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
%>
Sep 18 '06 #2
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
"JP SIngh" <no**@none.comwrote in message
news:uQ**************@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
%>

Sep 18 '06 #3
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...
Oct 13 '06 #4

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

Similar topics

5
by: John Lauwers | last post by:
Hi, Can I download a file automatically from internet, Just type the internet adress in a textbox and in another textbox the pad where it will be saved and then push a button so the downloaded...
6
by: Tony K | last post by:
I have the most peculiar problem with an ASP.NET page which we use for downloading a file. When the user clicks on a link, the link points to an ASPX page which downloads the file selected. ...
2
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
3
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
5
by: fniles | last post by:
We created an ActiveX control and marked it as safe for scripting using Implements IObjectSafety. We then created a CAB file and signed it using Verisign. We also created a license file (LPK file)...
4
by: aldonnelley | last post by:
Hi there: a bit of a left-field question, I think. I'm writing a program that analyses image files downloaded with a basic crawler, and it's slow, mainly because I only want to analyse files...
1
by: Maury | last post by:
Hello, I would like to download multiple files with one click in a web form link, I know how to download a single file, and I think that a solution is to zip all the files in an archive, and then...
3
by: xeroxero | last post by:
I would like to prevent people from downloading a .zip from a ASP.NET 2.0 web site, but still allow people to touch a .aspx page in the same directory. I also want to set things so if a user clicks...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.