Blob image not displaying in php

so i'm having a small problem in displaying a BLOB from my database , I tried everything but with no results , just some ugly characters , I know it's something silly but it drives me crazy , here is the code:


Add the printcontent[] function:

/**
 * Print the main body of the page
 *
 * @param Session $sess
 */
function printcontent[$sess] {
    echo "
"; if [!isset[$_FILES['lob_upload']]] { printform[]; } else { $blobdata = file_get_contents[$_FILES['lob_upload']['tmp_name']]; if [!$blobdata] { // N.b. this test could be enhanced to confirm the image is a JPEG printform[]; } else { $db = new \Oracle\Db["Equipment", $sess->username]; $sql = 'INSERT INTO pictures [pic] VALUES[EMPTY_BLOB[]] RETURNING pic INTO :blobbind'; $db->insertBlob[$sql, 'Insert Logo BLOB', 'blobbind', $blobdata]; echo '

New logo was uploaded

'; } } echo "
"; // content }

This is in the now familiar two part structure with an HTML form and a form-handler. The INSERT statement uses a bind value to represent the BLOB. The new Db class insertBlob[] will associate the BLOB data with the bind variable and commit the record. The uploaded image will be added to the PICTURES table.

Complete ac_logo_upload.php by adding the form function printform[]:

/**
 * Print the HTML form to upload the image
 *
 * Adding CSRF protection is an exercise for the reader
 */
function printform[] {
    echo save[] method inserts the data. Finally, an explicit oci_commit[] commits the BLOB. 

Run the AnyCo application in a browser and log in Administrator. Click the Upload Logo link in the left hand menu. Locate a JPEG image on your computer and select it. The next section of this chapter will display the image in the page header with the title, so choose an image of 15 to 20 pixels in height.

Click the Upload button.

Chủ Đề