We help IT Professionals succeed at work.

Classic ASP Download Question

pcalabria
pcalabria asked
on
Hello Experts.....

I have a file called myinventory.csv in the downloads directory of my website.
I would like to display a hyperlink on a webpage that says download inventory.
When the link is clicked, I would like the user to be able to select a folder on his local machine,
and download the file.

Can anyone give me code to display "Download Inventory" as a hyperlink and to perform this function?  The relative path of the file would be \downloads\myinventory.csv

This is what I have so far:

<a href='\downloads\myinventory.csv'>Download Inventory</a>
Comment
Watch Question

Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
That looks like it should work.

However, that link will work for anybody in the public that has the link to download inventory. Also, if somebody else runs a report that creates a file to \downloads\myinventory.csv then user1's file will get overwritten by user2.

One option is to make sure to name the file to something unique. Perhaps concatenate the username & year & month & day & hour & second like user120191027112315.csv  Or take that data and put it to an md5 hash to end up with 7344ede286decf63cd418220c6f4f66f.csv.

If the file needs to be saved on the server, then save it below the public www using FileSystemObject and give your 'vault' folder write permissions for the website user account.

You are still left with the file 7344ede286decf63cd418220c6f4f66f.csv open to the public (if they  have the url of course).  What I did in this case is have a button to remove the file the visitor can use to delete the file when they are done. In addition you can use create a scheduled task to run every thirty minutes to remove files that are older than 25 minutes.
Technology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013
Commented:
In my experience, URLs need / slashes, not \.

Try:
<a href='/downloads/myinventory.csv'>Download Inventory</a>

Author

Commented:
Thank you both for your help!!!
I will try to write code to read the date of the file and use it as part of the name.. but that’s a project for another day!

Author

Commented:
Your help is appreciated!  thanks you both!