How do u create a download link?
Moderator: General Moderators
How do u create a download link?
Can u create a php download link? Come to think of it, I don't really know how to create the link using straight html either...anyone?
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
actually i'm just trying to figure out how to create a link so users can download files from me. Every form of the <a href"//////"></a> that I try doesn't seem to work. Pretty simple I'm sure (and do I ever feel like a dummy for asking) but I can't find anything on the web about this and oddly enough, none of my html books cover this...lol go figure.
your path is probably incorect in the link.
if you file is in C:\inetpub\wwwroot\files\file.txt
and if your script or htm file is in the SAME directory, then the link should be
<a href="file.txt">File Link</a>
Remember that a link is "relative" to the path of the page displaying it.
What paths are the source and file in?
if you file is in C:\inetpub\wwwroot\files\file.txt
and if your script or htm file is in the SAME directory, then the link should be
<a href="file.txt">File Link</a>
Remember that a link is "relative" to the path of the page displaying it.
What paths are the source and file in?
uh, you could either make the link point to a php script that does a binary push to the client, or you could use javascript that tells the browser to download the file, not open it. Of course, with javascript you will have to account for the force download command for all the different types of browsers and as far as php goes, I don't know the function that you would use to open a binary connection to the client to push the file.
I'm sure that you can find an answer at http://www.php.net
Cheers!
I'm sure that you can find an answer at http://www.php.net
Cheers!
Code: Select all
<?php
header("Content-type: octet/stream");
header("Content-Disposition: attachment; filename=pic1.jpg");
readfile('pic1.jpg');
?>