dimanche 19 juin 2016

Image wont be recognized. Chrome extensions ajax [duplicate]


This question already has an answer here:

Pulling an image from with php from a MySQL server is always returning an error. I have tried for hours to find work arounds for Content Security Policies but I cant figure out this one. Now the image frames get loaded but the image would not be set. Here is my code.

inputImages.php

<?php
    $server_name = "localhost";
    $my_user = ""; //taken out for stackoverflow question
    $my_passcode = ""; //taken out for stackoverflow question
    $db_name = ""; //taken out for stackoverflow question
    $conn = mysqli_connect($server_name, $my_user, $my_passcode, $db_name);
    if (!$conn)
    {
        die("Could not connect");
    }
    else //Hopefully this runs instead  
    {
        try
        {
            $sql_query = mysqli_query($conn, "SELECT * FROM `adDatabase`");
            while ($row = mysqli_fetch_array($sql_query))
            {
                $id = $row['ID'];
                $img = $row['img'];
                $image = '<img src="data:image/png;base64,'.base64_encode( $row['img'] ).'" style="height: 12em; width: 12em" >';
                echo $image;
            }
        }
        catch(Exception $e)
        {
            echo $e;
        }
    }
?>

And the js file with ajax request

window.onload = function()
{
    $.ajax({
        url: '', //taken out for stackoverflow question
        success: function(data)
        {
            $(".latest-ads").html(data);
        }
    });
}

But nothing loads and I get this error

jquery.js:5873 Refused to load the image 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkAAAAHkCAYAAADW/5BTAAAYK2lDQ…FCoBAoBAqBQqAQOFIEarf3kTZcsV0IFAKFQCFQCBQCN0fg//rs0Cqe5CYQAAAAAElFTkSuQmCC' because it violates the following Content Security Policy directive: "default-src *". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.


Aucun commentaire:

Enregistrer un commentaire