How to provide a hyperlink to file without revealing path?

I need to provide an href / hyperlink in a web browser to a file, so that the user can open/download it, but NOT provide the full path to the file (for security reasons).

What's the best way to do this?
cdakzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineNo oneCommented:
Link to a server-side script of some sort that includes the file from another location and sends it back to the user.

Something like this:

http://www.yoursite.com/downloadafile.php

$file_url = 'http://www.yoursite.com/dont/browse/to/this/file.exe';
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); 
readfile($file_url); 

Open in new window

0
cdakzAuthor Commented:
I get the gist, but am familiar with asp.net/c#, so the php isn't clear.

Suggestion on how to do this in C# on ASP.NET? (Sorry I didn't say so in the beginning).
0
Jason C. LevineNo oneCommented:
Sorry, I don't work on Windows.  I will add those topics to your question so those Experts will see it.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

David Johnson, CD, MVPOwnerCommented:
use a virtual directory. http::\\sitename\path can point anywhere on that server.
0
cdakzAuthor Commented:
Jason C. Levine's suggestion pointed me in the right direction, even though it was from the LAMP world. I had in my head to somehow fool an <a href... tag to pull this off, which was wrong.

As it turns out, this is almost trivially simple in the ASP.NET MVC world (after looking in the right direction).

Here are 2 references if anybody else wants to know how to implement this using ASP.NET MVC:
www.prideparrot.com/blog/archive/2012/8/uploading_and_returning_files#how_to_return_a_file_as_response

MSDN's FileResult documentation
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason C. LevineNo oneCommented:
Thanks, cdakz.  Happy that I got you looking in the right direction.
0
cdakzAuthor Commented:
Selected my solution because it was the ASP.NET MVC solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.