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); 6 15998
Spam sucks wrote: 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
There is no way to do that on one call to a page. If you were so inclined, you
could put all that code into a PHP script that returns HTML or an image
depending on the variables sent to it, though I can't see an advantage to it.
The user's browser would still have to make 2 requests.
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
"Shawn Wilson" <sh***@glassgiant.com> schreef in bericht
news:3F***************@glassgiant.com... Spam sucks wrote: 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 There is no way to do that on one call to a page. If you were so
inclined, you could put all that code into a PHP script that returns HTML or an image depending on the variables sent to it, though I can't see an advantage to
it. The user's browser would still have to make 2 requests.
What i meant was this:
== document test.php ==
<?php
session_start();
session_register('data');
//insert in session is almost the same as an im field
//$filename="./picture.jpg";
//$_SESSION['data'] = fread(fopen($filename, "r"), filesize($filename));
// get the data from the session and converts it into a pic
if ($image)
{
Header("Content-type: image/jpeg");
$ima=$_SESSION['data'];
$im = imagecreatefromstring("$ima");
imagejpeg($im);
}
// calls the image
echo"<img src=\"test.php?image=1\">";
?>
Spam sucks wrote: "Shawn Wilson" <sh***@glassgiant.com> schreef in bericht news:3F***************@glassgiant.com... Spam sucks wrote: 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
There is no way to do that on one call to a page. If you were so inclined, you could put all that code into a PHP script that returns HTML or an image depending on the variables sent to it, though I can't see an advantage to it. The user's browser would still have to make 2 requests. What i meant was this:
== document test.php == <?php session_start(); session_register('data');
//insert in session is almost the same as an im field //$filename="./picture.jpg"; //$_SESSION['data'] = fread(fopen($filename, "r"), filesize($filename));
// get the data from the session and converts it into a pic if ($image) { Header("Content-type: image/jpeg"); $ima=$_SESSION['data']; $im = imagecreatefromstring("$ima"); imagejpeg($im);
} // calls the image echo"<img src=\"test.php?image=1\">"; ?>
I don't see why you couldn't do that, as long as the file was reasonably small
and you put an exit() after the imagejpeg($im) line to prevent the echo from
printing text into the jpeg file. But unless you have a really good reason, I
don't see why you'd save the image like that. You could just open the file and
use fpassthru() as needed.
Regards,
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
Using 2 file is better, I dont see any use to put condition on one file as
it's just more confusing, and perform slower.
Savut
"Shawn Wilson" <sh***@glassgiant.com> wrote in message
news:3F***************@glassgiant.com... Spam sucks wrote: "Shawn Wilson" <sh***@glassgiant.com> schreef in bericht news:3F***************@glassgiant.com... Spam sucks wrote: > > 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 There is no way to do that on one call to a page. If you were so inclined, you could put all that code into a PHP script that returns HTML or an
image depending on the variables sent to it, though I can't see an advantage
to it. The user's browser would still have to make 2 requests. What i meant was this:
== document test.php == <?php session_start(); session_register('data');
//insert in session is almost the same as an im field //$filename="./picture.jpg"; //$_SESSION['data'] = fread(fopen($filename, "r"), filesize($filename));
// get the data from the session and converts it into a pic if ($image) { Header("Content-type: image/jpeg"); $ima=$_SESSION['data']; $im = imagecreatefromstring("$ima"); imagejpeg($im);
} // calls the image echo"<img src=\"test.php?image=1\">"; ?>
I don't see why you couldn't do that, as long as the file was reasonably
small and you put an exit() after the imagejpeg($im) line to prevent the echo
from printing text into the jpeg file. But unless you have a really good
reason, I don't see why you'd save the image like that. You could just open the
file and use fpassthru() as needed.
Regards, Shawn -- Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
Shawn Wilson <sh***@glassgiant.com> writes: Spam sucks wrote: 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
There is no way to do that on one call to a page. If you were so inclined, you could put all that code into a PHP script that returns HTML or an image depending on the variables sent to it, though I can't see an advantage to it. The user's browser would still have to make 2 requests.
It *is* possible to embed image data in an HTML page, although not
all browsers handle it well. See the "data" scheme described in
RFC 2397: http://www.rfc-editor.org/rfc/rfc2397.txt
Here's an example:
<?php
$img = imagecreate(200, 100);
// Generate the image here.
ob_start();
imagepng($img);
$data = base64_encode(ob_get_contents());
ob_end_clean();
echo "<img width=200 height=100 src=\"data:image/png;base64,$data\">\n";
?>
The "data" scheme has always worked for me with browsers that are
kin to Mozilla. However, I've heard that Internet Exploiter has
problems with it, so it might not be suitable for general use.
--
Michael Fuhr http://www.fuhr.org/~mfuhr/
Michael Fuhr wrote: Shawn Wilson <sh***@glassgiant.com> writes:
Spam sucks wrote: 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
There is no way to do that on one call to a page. If you were so inclined, you could put all that code into a PHP script that returns HTML or an image depending on the variables sent to it, though I can't see an advantage to it. The user's browser would still have to make 2 requests.
It *is* possible to embed image data in an HTML page, although not all browsers handle it well. See the "data" scheme described in RFC 2397:
<snip>
Well, I'll be damned. Thanks for the tip. You learn something new every day
:o)
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dav |
last post by:
Hi all,
I am using these code to save Image to database:
Dim fs As FileStream = New FileStream(filename, _
FileMode.OpenOrCreate, FileAccess.Read)
Dim rawData() As Byte = New Byte(fs.Length) {}...
|
by: den 2005 |
last post by:
Hi everyone,
Here is code working on..Trying to insert record with a column with Image
or VarBinary datatype in sql database from a existing jpeg image file, then
retrieve this image from...
|
by: santybanty20 |
last post by:
i have some problem on ilplementing the code for the insertion of image into database that didnot get how to use the code for image storege.so can u help me in the use for the code by which i want to...
|
by: vivekgoyal |
last post by:
hello guys,
i need your help...
i face problem in storing image in database...
can any one send me the complete coding of storing image in database...
please i need ur help...
plz try to send me...
|
by: yashumrhsn |
last post by:
Hi.
Can anyone help me to write the code for inserting image into database? In my form there is a command button labelled 'save'. When click that button, it gets browse, from that we can select an...
|
by: =?Utf-8?B?SHVzYW0=?= |
last post by:
Hi EveryBody:
I have the following code that I used in my application to retive image from
database:
Dim cnn As New SqlConnection("Data Source=localhost;Initial
Catalog=Husam;Integrated...
|
by: keerthisreenu |
last post by:
hai to all...!!
iam working with Ms Access 2000.
iam saving an image in the database.
After that i want to retrive the same image from database and displaying it in the picture box.
but its not...
|
by: shivapadma |
last post by:
i have inserted the image into database using the following code
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/";
String dbName =...
|
by: brijesh1234 |
last post by:
dear Sir/madam
I am getting a problem while displaying a image from database
Database : MSSQL2000
I have a table named “Image” having following fields as
ImageId int
Image Image
|
by: selvasoft |
last post by:
Hi
Please help me i want display all images from my database.
but here my code that will display only one image from database.
But i want all images, any one help me.
<html>
<head>...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |