表单提交后显示$ _FILES ['image']

How do i display the image uploaded after the form has been submitted? After the form is submitted it will be a preview page, so i'm not storing the image type BLOB in MySQLyet. How do i display $_FILES['image']?

<?php

if(isset($_POST['submit'])) {

 //preview page

$info = getimagesize($_FILES['image']['tmp_name']);
$imagetype = $info['mime'];
$tmpname = $_FILES['image']['tmp_name'];
$fp = fopen($tmpname,'r');
$data = fread($fp,filesize($tmpname));
$data = addslashes($data);
fclose($fp);

} else {
?>

<form enctype="multipart/form-data" action="http://www.example.com/submit" method="POST">
<input type="file" name="image" value="" size="50" />
<input type="submit" name="submit" value="submit" />
</form>

<?php
}

?>

If you don't want to store the image on the server you can preview like this:

<?php
if (isset($_FILES['image'])) {
    $aExtraInfo = getimagesize($_FILES['image']['tmp_name']);
    $sImage = "data:" . $aExtraInfo["mime"] . ";base64," . base64_encode(file_get_contents($_FILES['image']['tmp_name']));
    echo '<p>The image has been uploaded successfully</p><p>Preview:</p><img src="' . $sImage . '" alt="Your Image" />;
}

But if you want to store it on the server, just store it and show it without changing the page.

i'm not storing the image type BLOB in MySQLyet. How do i display $_FILES['image']?

exactly the same way as if you stored it.

As "tmp_name" could suggest it's a temporary resource. Save it to disk, then show it, then remove it

 <?
 $preview_file = false;
 if(is_uploaded_file($tmpname) && $info=@getimagesize($tmpname)){
   $preview_file = "./tmp/tmp_preview.extension";
   move_uploaded_file( $tmpname, realpath($preview_file) );
 }
 if($preview_file){
   // show preview
 }