我想在“preview15.php”文件中显示我的“preview16.php”提交的图像。我正在使用 base64 编码,但它在 IE 7 中不起作用。我希望它在图像标签中。而且我不想将上传的图像存储在任何目录中。我的 preview16.php
<head>
</head>
<body>
<form method="post" id="target" enctype="multipart/form-data" action="preview15.php">
<input type="file" name="user_image" id="user_image" >
<input type="submit" name="save" />
</form>
</body>
</html>
我的 preview15.php 文件是这样的,
<?php
if(isset($_FILES['user_image'])){
$file_name = $_FILES['user_image']['name'];
$file_tmp = $_FILES['user_image']['tmp_name'];
echo '<img src="data:image/jpg;base64,'.$img_str.'" id="watermarked"/>';
$img_src = $file_tmp;
$imgbinary = fread(fopen($img_src, "r"), filesize($img_src));
$img_str = base64_encode($imgbinary) ;
echo '<img src="data:image/jpg;base64,'.$img_str.'" id="watermarked"/>';
}
?>