crazyswede Posted December 15, 2018 Share Posted December 15, 2018 Okay, I have several programs I wrote in ASP (classic)/JavaScript that I run on my website, feeding from and storing to MDB and txt files stored on the server. I Periodically want to download and save these files on my computer. Right now, I have to fire-up my big, elaborate FTP system - a long and lengthy process. I was wondering if (and how) I could write a program so I could just click on a button on my screen and download the file? Just point me in the right direction and I will figure it out. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 17, 2018 Share Posted December 17, 2018 The general method is to send the correct headers to tell the browser what kind of file it is, then read the file from disk and output the contents to the browser. Link to comment Share on other sites More sharing options...
crazyswede Posted January 7, 2019 Author Share Posted January 7, 2019 (edited) <%@ Language=JavaScript %> <HTML> <HEAD> Here, I’m guessing that “href=” section below refers to where the program goes to get the file to download from the server. The “download=” section I’m guessing Is where I tell the program where to download that file on my computer. I'm not entirely sure what the “img src=” section is for but we're not working with images so I am guessing I can leave in out <a href="http://ccs2468.com/books/books09.mdb" download="c:books09.xxx"> </a> <! img src="/images/myw3schoolsimage.jpg" alt="W3Schools"> </a> 4) I tried this too with no luck. <a href="/books/books09.mdb" download="c:books09.xxx"> </a> Done <-- I put this in just To show me that the program has run. But I run the program and then check on the computer, and nothing has been downloaded. what am I doing wrong? </BODY> </HTML> Edited January 7, 2019 by crazyswede clarify Link to comment Share on other sites More sharing options...
justsomeguy Posted January 7, 2019 Share Posted January 7, 2019 That's not valid HTML code, <a> tags and <img> tags don't go in the head section of the page. I'm not aware of any tag having a "download" attribute, either. If those files are already reachable on the web server then you just type the URL to the file in a browser to download it. I was assuming the files are not available in the web server root. If they are not, then you need to output the correct HTTP headers, and then send the contents of the file. HTTP headers have nothing to do with the head section inside an HTML document if you got confused about that. You use ASP or another server-side language to send the response headers. They tell the browser that you're sending a file of a certain type and size, what the name is, etc. They result in the browser showing the save/open dialog box. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now