你好,我使用此代碼輸出圖像從一個文件名爲圖像水珠功能輸出的所有文件
<?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>
當我運行代碼它輸出文件夾中的所有文件我有文件如test.php和文件作爲js和css和一個名爲圖像的文件當我運行它時輸出js和css以及所有.php文件文件把它不輸出圖像什麼錯誤
可能重複http://stackoverflow.com/questions/19543136/php -foreach和 - 圓頂封裝體功能) –