下面是我用来打开文件夹名称中有空格的文件夹的简化代码。
$path = ABSOLUTE_MEDIA_PATH."training/".$cfolder['folder']."/".$coursename."/";
$directory = opendir("$path");
while(false!==$file=readdir($directory)) {
echo $file;
}
正如您所看到的,我已将引号添加到文件夹路径,但它仍然无法正常工作。以下是我得到的错误
Warning: opendir(C:/xampp/htdocs/cdi1/media/training/profeuse/National Values and Principles of Governance/): failed to open dir: No such file or directory in C:\xampp\htdocs\cdi1\components\students\courses\showcoursedocs.php on line 12
Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\cdi1\components\students\courses\showcoursedocs.php on line 16