Downloading a local file...
I have a website running off a windows server in a client's office. I need to allow a file on another, local computer to be downloaded off the website. How can I link to the file?
At the moment I'm thinking the only way is to mount the directory containing the file onto one of the server's drives, and access it with a "../../../g:/somedirectory/file.txt"
Any suggestions? I haven't got a clue
Why don't you just pull that file over to the web server itself?
If you don't want to do this, you will probably need to setup an external ilp address for that pc and just link to the file with that ip.
Some things Man was never meant to know. For everything else, there's Google.
Can't set up an external IP to that machine, its not going to be set up as a web server
And I can't copy the file over as it gets updated every night
if you need to send the file through the webserver from the other machine you could try something like this
not sure whether you'll need to map the drive or not. depends whether an ado stream object can use a UNC path or not (which i've not tried).
filename = "d:\testfile.txt"
set ofso = createobject("scripting.filesystemobject")
if ofso.fileexists(filename) then
set ofile = ofso.getfile(filename)
Response.AddHeader "Content-Disposition", "attachment; filename=" & ofile.name
Response.AddHeader "Content-Length", ofile.size
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
set ofile = nothing
set oStream = createobject("adodb.stream")
oStream.type = 1
you might also want to change the headers being sent. at the moment it forces a download prompt to appear.
I've set filename to be "\\serverB\path\somefile.txt" but the "if ofso.fileexists(filename)" test returns false.
Does that mean that I can't use paths pointing to other servers on the network?
yeah. that's what i meant by using a unc path. if you map the drive you should be ok though i think.
Fantastic. If I map the drive though I won't need to use the above script?
depends how you want it to work. if you're happy to just set up another virtual directory pointing to your mapped drive then you don't need the script. however if you don't want to set up another virtual directory (maybe to hide other files in there) then you can send the file from within your existing application with the script.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)