473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to retrive image form oracle database using php

Hi,
I am working on one project which uses oracle as a database.
According to requirement I have to store image on oracle database in blob(datatype) and retrieve that stored image and show in a web page.
If I am doing so,I am getting a broken image the code is shown below:
Expand|Select|Wrap|Line Numbers
  1. $query = $pdo->prepare("SELECT image,type FROM image where s_date = ? ");
  2. $query->execute(array($dat));
  3. $res = $query->fetchAll();     
  4.     foreach ($res as $result){             
  5.         echo '<img height="300" width="500" src="data:'.$result['type'].';base64,' . base64_encode($result['image']) . '" />';
  6.  
  7.         }
  8.  
  9.  
  10.  
  11.  
  12.  
Jan 9 '16 #1
3 1771
Luuk
1,047 Expert 1GB
Try to look at the size of the image that you are retrieving..
Probably you will find out that you are not retrieving the same size as the image size that was stored.

If you base64_encode the picture before storing, *yes this will lead to bigger database contents!), you should be able to retrieve the complete image. (and base64_encode) would not be needed to display image)
Jan 9 '16 #2
MY image size is in kb.
Jan 11 '16 #3
Luuk
1,047 Expert 1GB
"MY image size is in kb."

This cannot be true!

Maybe your image size is displayed in kb.
But kb is short for kilobytes, which seems to be 1024 bytes.

My question was:
What size is the image (not with which unit is this size displayed)

Ig you have an image with a certain size(1), store it in the database, and retrieve it, what is the new size(2)

Calculatie the difference between these sizes ((1) and (2)). The difference in size should be bytes.

Can/Did you verify that?

If the outcome of this difference is not 0 (zero) than you will see a broken image.
Jan 16 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bassem | last post by:
Hi all... I searhed for a code to save and retrieve image from SQL database using Data adapter but I didn't found anything. Thanks, Bassem.
0
by: otto | last post by:
Hi, all: We have a Windows application that make operations against an Oracle database. The business logic components are in the server and are accesible from the client interface trought a...
2
by: Steve Kershaw | last post by:
I have a need to extract data from an Oracle database using an SQL query. The problem is that I need to insert a parameter into the query. For example: SELECT EMPLOYEE, DED_CODE FROM QUARTDED...
1
by: Master Ken | last post by:
Hi All, I'm very new to C# and ASP and I am asking for some help as I don't really know where to start on this project. Some background info first I run a report each week which outputs data...
2
by: chinnaits | last post by:
how to retrive image from the database
5
by: sumanta123 | last post by:
Dear Sir, How to export/import the excel file in oracle database using sql promt. Please guide me the command(export/import) for the neddful. Thanks in Adavance. Regards Sumanta Panda
0
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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 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.