Link to home
Start Free TrialLog in
Avatar of pcalabria
pcalabriaFlag for United States of America

asked on

Classic ASP Download Question

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>
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pcalabria

ASKER

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!
Your help is appreciated!  thanks you both!