Page 1 of 1

Hiding a link..

Posted: Thu Dec 23, 2004 9:05 am
by snicolas
SOmebody has an example on how to do this?

I propose my members to download the document X, but would like to keep the location of this document "secret"

What can i do to hide the <a href="docs/document.doc"> LINK?

ta

s

Posted: Thu Dec 23, 2004 10:53 am
by snicolas
Found my solution and posting it , thought it might be usefull for others...

So if you want to allow the download of important document without giving a straight url
ex: <a href="DOCUMENT.ZIP">DOC</a>

So to do

1/ Create a folder with reading permissions outside your webroot (/user/home/FOLDER NAME)
2/ Create a file called download.php and copy this code
<?php
$file= $_GET["file"];

if (!isset($file)) {

echo "<font face=\"tahoma\" size=\"2\">No File Specified</font>\n";

} else {

header("Cache-control: private");
header("Content-Type: application/force-download; name=\"$file\"");
header("Content-Disposition: attachment; filename=\"$file \"");
header("Content-Transfer-Encoding: binary");

$fp = fopen('/usr/home/FOLDER NAME/'.$file,"r");
fpassthru($fp);
fclose($fp);

}

?>
3/ In your web page, where you want to display the link for downlaod, do:
<a href="download.php?file=DOCUMENT.ZIP">DOCUMENT</a>

et voila...

Merry christmas

s

Re: Hiding a link..

Posted: Sun May 04, 2008 4:39 am
by html20009876
Hi snicolas,

Your reply is a wonderful help for me.

Cheers