Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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 &引用;要求参数1为有效路径,字符串为“给定”;_Php - Fatal编程技术网

Php &引用;要求参数1为有效路径,字符串为“给定”;

Php &引用;要求参数1为有效路径,字符串为“给定”;,php,Php,我想我手上可能有一只海森堡。到目前为止,我的代码如下所示: $enc = $_REQUEST['l']; $filename = DecryptString($enc); echo $filename; //Displays: uploads/Maid with the Flaxen Hair.mp3 if (is_dir($filename)) //Gives the error: "Warning: is_dir() expects parameter 1 to be a vali

我想我手上可能有一只海森堡。到目前为止,我的代码如下所示:

$enc = $_REQUEST['l'];
$filename = DecryptString($enc);

echo $filename;  //Displays: uploads/Maid with the Flaxen Hair.mp3


if (is_dir($filename))  //Gives the error: "Warning: is_dir() expects parameter 1 to be a valid path, string given"
{

    Download($filename);
}
然而,如果我将前面的内容作为echo,即
uploads/Maid with the flashen Hair.mp3
,并运行
is_dir(“uploads/Maid with the flashen Hair.mp3”)
,它将按预期返回

因此,如果我将变量传递到
is_dir
,它将失败,但如果我传递变量的值,它将工作。问题是什么?

DecryptString()
返回一个字符串,该字符串的末尾带有NULs(
\0

在尝试使用该值之前,请确保将其修剪掉


您可以使用
$enc=trim($enc)修剪空字符

检查目录上的权限?如果apache用户无法读取,is_dir很可能会失败