如何在formhandler中使用PHP查看输入表单的图像文件是否已经在文件系统中
这是我的代码,但它永远不会返回true如何在formhandler中使用PHP查看输入表单的图像文件是否已经在文件系统中,php,filesystems,file-exists,Php,Filesystems,File Exists,这是我的代码,但它永远不会返回true $image = $_FILES['image']; $filename = $image['name']; $filepathname = "/$membername/"."$filename"; if (file_exists($filepathname)) { throw new Exception('Image already exists'); } “$membername”是否包含$\
$image = $_FILES['image'];
$filename = $image['name'];
$filepathname = "/$membername/"."$filename";
if (file_exists($filepathname)) {
throw new Exception('Image already exists');
}
“$membername”是否包含$\u服务器['DOCUMENT\u ROOT']路径
阅读更多@
(如果它确实包含$\u服务器['DOCUMENT\u ROOT'],则您可能需要检查文件权限(假设您使用的是LAMP)搜索“相对路径”:而且您不希望将用户提供的值直接用于任何路径操作。过滤器,至少
basename
。为什么您认为它应该为您返回true?file\u是否存在($knownExistingFilename)
返回true?knownExistingFilename
是否与上面的filepathname
的值匹配?