Experts Round Table Network

Serverside Technology => PHP => Topic started by: spotonukraj on February 07, 2008, 03:05:52 PM



Title: how to get images from mysql database path
Post by: spotonukraj on February 07, 2008, 03:05:52 PM


 Hi,

 I m new to php. i designed form were this are the fields : Name, email, phone No. & photo.

 I uploaded this data to database as well, were for imagedata i just save the path in sql
table and image in folder called images on server.

when i fetching all data except image part all text data viewing properly, i m not able to get images the images place look like broken link on html page. I put that header as well

header content (content type images/jpeg) but it not working. I am looking for somone help me out.


Title: Re: how to get images from mysql database path
Post by: rdivilbiss on February 07, 2008, 05:36:47 PM
Well it is certainly possible to load images into a database as binary objects but it is a complete waste of resources.

If you want the "how to" as a object lesson in what not to do we can provide that, but if you want efficiency, load the images natively to the file system and store only the path/filename in the database.

Easier to maintain and significantly faster, both in terms of development and maintenance, as well as server time to actually present the image to the browser.


Title: Re: how to get images from mysql database path
Post by: CrYpTiC_MauleR on February 07, 2008, 10:35:44 PM
>> header content (content type images/jpeg)

are you putting it as this in your PHP file?

header('Content-Type: image/jpeg');

Remember must be put BEFORE any content is sent to browser, and the MIME type is image/jpeg not images/jpeg, see if that helps. By the way is the page accessible to us? If so can you post the link so we can visit it and see what could be happening in the request?