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
Hiding a link..
Moderator: General Moderators
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
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
-
html20009876
- Forum Newbie
- Posts: 3
- Joined: Sun May 04, 2008 3:42 am
Re: Hiding a link..
Hi snicolas,
Your reply is a wonderful help for me.
Cheers
Your reply is a wonderful help for me.
Cheers