tags:

views:

70

answers:

4

I've tried googling but the results returned arnt the ones i want. What i'm after is html code thank links to a file so it can be downloaded.

For example if i have file1.txt on my hard drive. How would I link it so it can be downloaded?


EDIT

I have tried:

<a href="/home/rv/ncbi-blast-2.2.23+/j1053.fasta">Download Results</a>

A: 

If your domain is example.com, try this:

http://example.com/file1.txt

If your webserver is setup correctly, it'll serve the correct file.

A link in html would look like this:

<a href="http://example.com/file1.txt"&gt;Click Here To Download File1.txt</a>
Matthew
+2  A: 

You can't link to a file on your hard drive, unless your hard drive is somehow accessible via the internet or web server.

Linking to a file is the same as linking to another page, just with file1.txt instead of whatever.html

http://www.w3schools.com/HTML/html_links.asp

BobTurbo
The file im looking to download isnt in the same folers as the html files? would it still work the same?
Sarah
@Sarah: Sure, but you'd need to use either a relative path from the HTML file, or an absolute path from the document root, or a full URL.
Ignacio Vazquez-Abrams
+1  A: 

This can't be done in just HTML, since both the server and the browser are configured to display the .txt file instead of offering to download it. You'll need to configure the server to use a MIME type for the file that will prompt the browser to download it, such as application/octet-stream.

Ignacio Vazquez-Abrams
A: 

If you want to put up a webpage that links to a file on your Desktop (and have it "just work"), try using something like Tonido or the Opera browser.

lucideer