【发布时间】:2014-02-21 08:49:47
【问题描述】:
您好,我正在使用此代码从名为 images 的文件中输出图像
<?php
//Path to folder which contains images
$dirname = $_POST['dir'];
//Use glob function to get the files
//Note that we have used " * " inside this function. If you want to get only JPEG or PNG use
//below line and commnent $images variable currently in use
$images = glob($dirname."*");
//Display image using foreach loop
foreach($images as $image) {
//print the image to browser with anchor tag (Use if you want really :) )
echo '<p><img style="height:176px; width:221px; float:right;" src="'.$image.'" /></p>';
}
?>
我把它命名为image.php,我用这个表单让用户选择目录
<form method="POST" action="image.php">
<input type="text" name="dir" placeholder="choose directory" />
<input type="submit" value="choose" />
</form>
当我运行代码时,它会输出文件夹中的所有文件把它不输出图像是什么错误
【问题讨论】:
标签: php