You are here: Re: file protection « PHP Programming Language « IT news, forums, messages
Re: file protection

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация