2010-02-25 57 views
1

我有这个脚本,当我尝试运行它时,它只是说等待本地主机,从来没有真正运行。如果我去我的本地主机,我可以运行其他文件没有问题。php noob-file上传脚本问题

这个脚本有什么问题?

<?php 
    $dir = 'Images/uploaded/'; 
    if($handle = opendir($dir)) { 
     $file = readdir($handle); 

     while($file !== false) { 
      echo "<li><img class=\"thumb\" src=\"".$dir.$file."\" /></li>"; 
     } 
    } 

    closedir($handle); 
?> 

回答

3

你并没有修改循环内的$file$file从不改变,因此你有一个无限循环。

http://php.net/readdir

/* This is the correct way to loop over the directory. */ 
while (false !== ($file = readdir($handle))) { 
    echo "$file\n"; 
} 
1

您需要在循环中调用readdir()