不能回显php、html中的image-data


cannot echo image-data in php, html

我是一个PHP新手,我不能在PHP中显示图像数据。我试了1个小时,但不能理解这个问题。请帮助。

<?php
ini_set('mysql.connect_timeout',300);
ini_set('default_socket_timeout',300);
?>

    <form method="post" enctype="multipart/form-data">
    <br/>
        <input type="file" name="image"/>
        <br/><br/>
        <input type="submit" name="submit" value="Upload"/>
    </form>
    <?php
        if(isset($_POST['submit'])
        {
                   $imagedata=mysql_real_escape_string(file_get_contents($_FILES["image"],["tmp_name"]));
            echo $imagedata;
        }
        else
        {
            echo "there has been some error";
        }
    ?>
</body>

修复代码:
<!DOCTYPE html>
<html>
    <head>
    </head>
<body>
    <form method="post" enctype="multipart/form-data">
        <input type="file" name="image">
        <input type="submit" name="submit" value="Upload">
    </form>
    <?php
        if(isset($_POST['submit'])) {
            $imagedata=file_get_contents($_FILES["image"]["tmp_name"]);
            echo $imagedata;
        } else {
            echo "there has been some error";
        }
    ?>
</body>
</html>

然而,这只会输出二进制数据。如果你想实际显示图像,你需要做更多的事情。