472,961 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Image return /print

me
Hey all,
well i am also a newbie :)

i saw this on many sites:
<img src="somephp.php?blabla" width="100">

how can i make that to?

i want to reffer to a php file that returns or prints a jpg image and in the
<img src=must be a php url>

Best regards M
Jul 17 '05 #1
7 15099
me wrote:
Hey all,
well i am also a newbie :)

i saw this on many sites:
<img src="somephp.php?blabla" width="100">

how can i make that to?

i want to reffer to a php file that returns or prints a jpg image and in
the <img src=must be a php url>

Best regards M


Hi,

You should somephp.php?blabla return an image, including the right headers
for MIME-TYPE and such.
Should work as you described above.

The trouble will be generating a script that does that. You will have to do
some more research on imagelibs in PHP.

Good luck,
Erwin Moller
Jul 17 '05 #2
me

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.xs4all.nl...
me wrote:
Hey all,
well i am also a newbie :)

i saw this on many sites:
<img src="somephp.php?blabla" width="100">

how can i make that to?

i want to reffer to a php file that returns or prints a jpg image and in
the <img src=must be a php url>

Best regards M
Hi,

You should somephp.php?blabla return an image, including the right headers
for MIME-TYPE and such.
Should work as you described above.

The trouble will be generating a script that does that. You will have to

do some more research on imagelibs in PHP.

Good luck,
Erwin Moller


Thanks,

i did some testing with this code:

header("Contet-type: image/jpeg");
$theURL="image.jpg";
if(!($fp=fopen($theURL,"rb")))
{
print("Could not open the URL.");
exit;
}
$contents=fread($fp,1000000);
print($contents);
fclose($fp);
But must i always set the header("Contet-type: image/jpeg") before the code
begins or can i make first a musql query orso to get the rigth image and
then print the header("Contet-type: image/jpeg");?
Jul 17 '05 #3
me wrote:

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.xs4all.nl...
me wrote:
> Hey all,
> well i am also a newbie :)
>
> i saw this on many sites:
> <img src="somephp.php?blabla" width="100">
>
> how can i make that to?
>
> i want to reffer to a php file that returns or prints a jpg image and
> in the <img src=must be a php url>
>
> Best regards M
Hi,

You should somephp.php?blabla return an image, including the right
headers for MIME-TYPE and such.
Should work as you described above.

The trouble will be generating a script that does that. You will have to

do
some more research on imagelibs in PHP.

Good luck,
Erwin Moller


Thanks,

i did some testing with this code:

header("Contet-type: image/jpeg");


that is content-type, no contet-type.
$theURL="image.jpg";
if(!($fp=fopen($theURL,"rb")))
{
print("Could not open the URL.");
this is a bit odd. You have set the header to image, but your output is
plain text..
Not good.

Your html-page is asking for an image, and your script should return one.
In your case, where it cannot find the right image, try to send back an
image you know that exists containing "NOT AVAILABLE" written on it or
somethinf like that.
Do not send plain text to the browser when it expects an image.
Better write an error to some logfile.
exit;
}
$contents=fread($fp,1000000);
print($contents);
fclose($fp);
But must i always set the header("Contet-type: image/jpeg") before the
code begins or can i make first a musql query orso to get the rigth image
and then print the header("Contet-type: image/jpeg");?


You can do whatever you like AS LONG AS YOU DO NOT GENERATE OUTPUT.
:-)
The headers should come first.

Jul 17 '05 #4

On 29-Sep-2003, "me" <so*****@microsoft.com> wrote:
i saw this on many sites:
<img src="somephp.php?blabla" width="100">

how can i make that to?


<img src="getimage.php?fn=image1" ...>

getimage.php:
<?php

if (isset($_GET['fn']))
$image = $_GET['fn'];
else
$image = 'error';

header("Content-Type: image/jpeg\n");
header("Content-Transfer-Encoding: binary");

$fp=fopen("images/$image.jpg" , "r");
if ($fp)
fpassthru($fp);

?>
--
Tom Thackrey
www.creative-light.com
Jul 17 '05 #5

"me" <so*****@microsoft.com> wrote in message
news:Yv***********************@pollux.casema.net.. .

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.xs4all.nl...
me wrote:
Hey all,
well i am also a newbie :)

i saw this on many sites:
<img src="somephp.php?blabla" width="100">

how can i make that to?

i want to reffer to a php file that returns or prints a jpg image and in the <img src=must be a php url>

Best regards M
Hi,

You should somephp.php?blabla return an image, including the right headers for MIME-TYPE and such.
Should work as you described above.

The trouble will be generating a script that does that. You will have to

do
some more research on imagelibs in PHP.

Good luck,
Erwin Moller


Thanks,

i did some testing with this code:

header("Contet-type: image/jpeg");
$theURL="image.jpg";
if(!($fp=fopen($theURL,"rb")))
{
print("Could not open the URL.");
exit;
}
$contents=fread($fp,1000000);
print($contents);
fclose($fp);
But must i always set the header("Contet-type: image/jpeg") before the

code begins or can i make first a musql query orso to get the rigth image and
then print the header("Contet-type: image/jpeg");?


Maybe try "Content-type" and not "Contet-type" :)
Jul 17 '05 #6
On Mon, 29 Sep 2003 15:54:32 GMT, "Tom Thackrey"
<to***@creative-light.com> wrote:
<img src="getimage.php?fn=image1" ...>

getimage.php:
<?php

if (isset($_GET['fn']))
$image = $_GET['fn'];
else
$image = 'error';

header("Content-Type: image/jpeg\n");
header("Content-Transfer-Encoding: binary");

$fp=fopen("images/$image.jpg" , "r");
if ($fp)
fpassthru($fp);

?>


another way to do it:

getimage.php:
<?php
if (isset($_GET['fn']))
{
$image = $_GET['fn'];
header("Location: images/$image.jpg");
}
else
{
header("HTTP/1.0 404 Not Found");
}
?>

- allan savolainen

Jul 17 '05 #7
Jason wrote:

"me" <so*****@microsoft.com> wrote in message
news:Yv***********************@pollux.casema.net.. .

"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:3f***********************@news.xs4all.nl...
> me wrote:
>
> > Hey all,
> > well i am also a newbie :)
> >
> > i saw this on many sites:
> > <img src="somephp.php?blabla" width="100">
> >
> > how can i make that to?
> >
> > i want to reffer to a php file that returns or prints a jpg image and in > > the <img src=must be a php url>
> >
> > Best regards M
>
> Hi,
>
> You should somephp.php?blabla return an image, including the right headers > for MIME-TYPE and such.
> Should work as you described above.
>
> The trouble will be generating a script that does that. You will have
> to

do
> some more research on imagelibs in PHP.
>
> Good luck,
> Erwin Moller


Thanks,

i did some testing with this code:

header("Contet-type: image/jpeg");
$theURL="image.jpg";
if(!($fp=fopen($theURL,"rb")))
{
print("Could not open the URL.");
exit;
}
$contents=fread($fp,1000000);
print($contents);
fclose($fp);
But must i always set the header("Contet-type: image/jpeg") before the

code
begins or can i make first a musql query orso to get the rigth image and
then print the header("Contet-type: image/jpeg");?


Maybe try "Content-type" and not "Contet-type" :)


Hi Jason,

That might help maybe. ;-)

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Henri Schomäcker | last post by:
Hi folks, I got a windows com executable which returns a jpg image in a BSTR. Let's say, the var that holds the data is $imgData. With perl, in a cgi script, I may simpy write:...
9
by: Steffen Brodowski | last post by:
Hello everyone, since one week, I'm programming with python. Its a realy interesting tool. I wrote a script for generating barcodes in jpg-format. Everything is ok, but my function...
9
by: matthiasjanes | last post by:
Hi, Maybe someone of you can help me. I'm trying to display an image in memory(open file) with an cgi script - but it want work proberly: I'm running an Cgi webserver (CgiServerGui.py). ...
17
by: PyPK | last post by:
Hi I am looking for a simple tiff Image reader/writer in python.Can anyone point me to the right one.
5
by: Tompa | last post by:
Hi, I would like to create images on the fly as a response to an http request. I can do this with PIL like this (file create_gif.py): from PIL import Image, ImageDraw print 'Status: 200 OK'...
1
by: Jason | last post by:
For some reason, most but not all reports printing from an access application our client is using will not print any images on the reports or forms. One report will print the image and data...
0
by: Sergei Shelukhin | last post by:
I need to generate an image to print on a small card (15cm x 5cm), the image will be cut from the standart a4 sheet; it was done by MS Access proggie before and I'm rewriting it into ASP.NET. I...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.