错误: 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函数有价值?