Thursday, August 8, 2013

PHP display images in a directory

<?
    ini_set("memory_limit","256M");
    if (!isset($_POST["id"])) {
        $id = 0;       
    } else {
        $id = $_POST["id"];
    }

    $lines = file("img.txt", FILE_IGNORE_NEW_LINES);
    echo "<br /><br /><center><img src='$lines[$id]'/><br /></center>";
    $id++;

echo '<form action="get_image.php" method="post">';
echo '<center>';
echo "id: <input type=\"text\" name=\"id\" value=\"$id\"><br />";
echo '<input type="submit">';
echo '</center>';
echo '</form>';
?>

File img.txt:
4342342.png
8539750.png
3257398.png

No comments: