hello,
i want to have an image in a variable so i can show it were ever i want the
only catch is that i want the image to be called in the same page, i found
this script but the problem is that you have to have an extra page to call
the image.
look at print_image.php
is there a solution or is it just not possible without having two pages
thanks in advance
G
the script=========================
by Elena Mitovska on February 18 2003, 02:10
Inserting images into database, field for storing image must be BLOB type:
to choose image user:
Upload.php
<form name='MyForm' method=post enctype="multipart/form-data"
action='Dofile.php'><input type=file name='userfile'><input type=submit
value=Upload">
Dofile.php:
$data = "";
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
//get file
$fp = fopen($userfile, "rb");
while(!feof($fp))
{
$data .= fread($fp, 1024);
}
fclose($fp);
$data = addslashes($data);
$data = addcslashes($data, "\0");
//insert image into database
$Query = "INSERT INTO images VALUES (NULL,'$data')";
$res = $db->query($Query);
OutputImages.php
<img src="print_image.php?id=$id>
print_image.php
$MainSQL="SELECT image FROM images where id=$id;
$res = $db->query($MainSQL);
$data = $res[0][0];
header("Content-Type: image/jpeg\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . strlen($data) . "\n");
//send file contents
print($data);