Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何拒绝对txt文件的web访问?_Php_Security_Web - Fatal编程技术网

Php 如何拒绝对txt文件的web访问?

Php 如何拒绝对txt文件的web访问?,php,security,web,Php,Security,Web,如何拒绝访问txt,不显示web浏览器名称.txt文件 $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[

如何拒绝访问txt,不显示web浏览器名称.txt文件

$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);
$filename=“/txt/name.txt”;
$handle=fopen($filename,'r');
$data=fread($handle,filesize($filename));
$rowsArr=行($data);

对于($i=0;$i文件名只不过是字符串:

if( substr($filename, -4)=='.txt' ){
    echo 'Access denied';
}
但是,如果您接受来自用户的文件名,则应添加进一步的检查,特别是关于路径的检查。

可能存在重复的文件名