Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fetch Blob image from database and save in file

Hassan MahmoodNov 24 2014 — edited Nov 24 2014

Hi,

I am using the following code to fetch a picture stored in database (blob type)

$sql = "SELECT PICTURE FROM NEW_PICT WHERE SR_NO = 1";

$stid = oci_parse($conn, $sql);

oci_execute($stid);

if(OCIFetch($stid)) //if file exists

{

$a=OCIResult($stid,"PICTURE");

}

file_put_contents('pics/test.jpg', $a->load());

The code works fine with no errors and it generate the picture "test.jpg". The image also opens in windows image viewer.

But when I try to open this image with Photoshop or any other image editing tool, the error occur "Invalid JPEG Marker" or "Invalid File Type"

Also the image dose not display in browser.

Please help.

Thanks

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 22 2014
Added on Nov 24 2014
1 comment
2,042 views