[英]php noob-file upload script problems
我有这个脚本,当我尝试运行它时,它只是说等待localhost并且从未实际运行。 如果我去我的localhost我可以运行其他文件没有问题。
这个脚本有什么问题?
<?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);
?>
你不是在循环中修改$file
。 $file
永远不会改变,因此你有一个无限循环。
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
你需要在循环中调用readdir()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.