Php 文件存在并捕获所有搜索

Php 文件存在并捕获所有搜索,php,file,Php,File,我正在查找文件是否存在。我知道它的名字,但我不知道分机。我可以在PHP方面做些什么,以便在不知道文件扩展名的情况下检查文件是否存在 file_exists('image_storage/ses_' . $session_user_id . 'need to put something here for the extension' ); 您可以使用PHP函数获取与给定模式匹配的文件列表: $files = glob('image_storage/ses_' . $session_user_i

我正在查找文件是否存在。我知道它的名字,但我不知道分机。我可以在PHP方面做些什么,以便在不知道文件扩展名的情况下检查文件是否存在

file_exists('image_storage/ses_' . $session_user_id . 'need to put something here for the 
extension' );
您可以使用PHP函数获取与给定模式匹配的文件列表:

$files = glob('image_storage/ses_' . $session_user_id . '.*');
if (count($files) > 0) {
    // check your files with a loop
    foreach ($files as $file) {
        // do whatever you want; this file exists =]
    }
}
您不需要使用
glob
检查文件是否存在;如果它在数组中返回它,它应该存在。

您可以使用PHP函数获取与给定模式匹配的文件列表:

$files = glob('image_storage/ses_' . $session_user_id . '.*');
if (count($files) > 0) {
    // check your files with a loop
    foreach ($files as $file) {
        // do whatever you want; this file exists =]
    }
}

您不需要使用
glob
检查文件是否存在;如果它在数组中返回它,它应该存在。

如果您在linux中,您可以这样做

$ret = exec("ls image_storage/ses_" . $session_user_id."*");
if(!empty($ret))
{
  //file exists..
}

如果你在linux中,你可以做到这一点

$ret = exec("ls image_storage/ses_" . $session_user_id."*");
if(!empty($ret))
{
  //file exists..
}
他是你的朋友。他是你的朋友。