错误:readdir() 期望参数 1 是资源,给定字符串
$directorypremium = 'uploads/premium/'.text2url($pseudo_cookies).'/';
while($file = readdir($directorypremium)) {
if($file != '.' AND $file != '..')
{
$taille_fichier = filesize($directory.$file); $taille_fichier = round($taille_fichier / 1000); $total_size = $total_size + $taille_fichier;
}
}
我的函数 text2url:
function text2url($chaine)
{
$chaine = htmlentities($chaine, ENT_NOQUOTES, 'utf-8');
$chaine = preg_replace('#\&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring)\;#', '\1', $chaine);
$chaine = preg_replace('#\&([A-za-z]{2})(?:lig)\;#', '\1', $chaine);
$chaine = preg_replace('#\&[^;]+\;#', '', $chaine);
$chaine = preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $chaine);
$chaine = str_replace('(', '', $chaine);
$chaine = str_replace(')', '', $chaine);
$chaine = str_replace('[', '', $chaine);
$chaine = str_replace(']', '', $chaine);
$chaine = str_replace('.', '-', $chaine);
$chaine = trim($chaine);
$chaine = str_replace(' ', '_', $chaine);
return $chaine;
}
我知道问题是 $chaine 是一个字符串值,但我无法解决问题以使其被 readdir 接受。有没有办法让 $chaine 对 readdir 函数有价值?