Posted by Pedro Graca on 12/23/05 02:17
Yannick Benoit wrote:
> anyone can tell me a way to protect files from being downloaded from other
> sites using php ?
You may want to take a peep at
http://www.php.net/unlink
SCNR
Or even readfile @ http://www.php.net/readfile
Put the files outside the web directory, validate the access and serve
the files (or not) with readfile().
<?php
$done = false;
if ($_SESSION['ok_to_download']) {
$filename = convert_id_to_filename((int)$_GET['id']);
clearstatcache();
if (($filename !== false) && (file_exists($filename)) && (is_readable($filename))) {
// send headers
// readfile($filename);
$done = true;
}
}
if (!$done) {
header('Content-Type: text/plain');
echo 'You can\'t do that now.';
}
?>
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Navigation:
[Reply to this message]
|