1

I'm trying to show an image saved from SQL Server from the database to the php page I am creating. What I've done so far is I get the necessary data from the database, which is the image , and the image type(if its a jpg).

This is what I did:

            $idata = base64_decode($imageResult);
            imagejpeg($idata);

But it is showing an error of the following:

 imagejpeg() expects parameter 1 to be resource, string given [APP\Controller\MainController.php, line 226]

How do I make the image show inside my php? Do I need to decode the data that I'm getting from the database before I could convert it?

I want to give an example but the data that I currently have is very sensitive, which is why I don't know how I could give an example.

1 Answer 1

1

Use the imagecreatefromstring function: http://www.php.net/manual/en/function.imagecreatefromstring.php

$idata = base64_decode($imageResult);
$image = imagecreatefromstring($idata)
imagejpeg($image);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.