WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.8 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • General Community »
  • Global WebsiteBaker 2.8.x discussion »
  • Calling a PHP script from inside an <img src.. in code section
  • Print
Pages: [1]   Go Down

Author Topic: Calling a PHP script from inside an <img src.. in code section  (Read 17084 times)

POPDUM

  • Guest
Calling a PHP script from inside an <img src.. in code section
« on: February 02, 2008, 01:22:55 PM »
Hi,

I have to retrieve images stored as BLOBs inside of a MySQL DB, and then display them on a page.

Since these BLOBs need to be preceded by a header, I am trying to use a PHP script to output them on the screen. In my code section, I use a statement like:

echo '<img src="myscript.php?pic_num=2" />'; or echo "<img src=\"myscript.php?pic_num=2\" />";

No image is displayed in either case, and it is no wonder because when I see the image properties, it seems that an attempt is made to display myscript.php itself. Is there any way I can invoke myscript.php?

Or is there someone who has successfully implemented something like what I am trying to do.

Any help will be most appreciated!
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Calling a PHP script from inside an <img src.. in code section
« Reply #1 on: February 02, 2008, 05:38:24 PM »
You will have to tell the browser that a picture is being sent.

Before sending the image data, do the following in your PHP script.

Quote
header("Content-type: image/png");

(or image/jpg image/gif etc)

That should help.

Cheers,

Ruud
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

POPDUM

  • Guest
Re: Calling a PHP script from inside an <img src.. in code section
« Reply #2 on: February 05, 2008, 10:37:44 AM »
Hi Ruud,

I am sending the content-type header, and it works when I try it from PHP/HTML, without the WB code section. Anyway, I resolved the issue by having the system store the images in files and storing the filenames in MySQL.

Thanks a lot for your help!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • General Community »
  • Global WebsiteBaker 2.8.x discussion »
  • Calling a PHP script from inside an <img src.. in code section
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2