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很可能会失败