我尝试了以下代码来检查根目录中文件的存在。
if($res['profile_picture']!="" && file_exists("images/".$res['users_id']."/thumnails/".$res['profile_picture'])){
$photo_p="images/".$res['users_id']."/thumnails/".$res['profile_picture'];
}
Run Code Online (Sandbox Code Playgroud)
它仅适用于根目录,不适用于子目录。
我不确定函数file_exist是否同时检查绝对路径和相对路径,所以我尝试添加ROOT和$_SERVER['DOCUMENT_ROOT']。但是仍然没有解决。
有帮助吗?