Reputation: 43
how to deny access to txt, dont's show web browser name.txt file?
$filename = "/txt/name.txt";
$handle = fopen($filename, 'r');
$data = fread($handle, filesize($filename));
$rowsArr = explodeRows($data);
for($i=0;$i<count($rowsArr);$i++) {
$lineDetails = explode("|",$rowsArr[$i]);
if ($kodas == $lineDetails[2]) {
$link3=$lineDetails[4];
echo "";
} }
fclose($handle);
Upvotes: 1
Views: 177
Reputation: 146460
File names are nothing but strings:
if( substr($filename, -4)=='.txt' ){
echo 'Access denied';
}
But if you're accepting file names from the user you should add further checks, esp. regarding paths.
Upvotes: 1