Php 从ajax中读取图像作为数据uri

Php 从ajax中读取图像作为数据uri,php,ajax,Php,Ajax,我有这个密码 $('.image').css({"background-image": "url('images/ajax-loader2.gif')",'background-size':'25%','background-position':'50%'}); $.get('php/loadImage.php?id='+imgData+'&d='+(new Date()).getMilliseconds(),function(img){

我有这个密码

            $('.image').css({"background-image": "url('images/ajax-loader2.gif')",'background-size':'25%','background-position':'50%'});
            $.get('php/loadImage.php?id='+imgData+'&d='+(new Date()).getMilliseconds(),function(img){
                $('.user').html('<div style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;background: url(data:image/jpg;base64,'+img+') no-repeat ; background-size: cover;width:100%;" class="image"></div>');
            });

问题是如何使图像可见?

图像不属于数据库,而是属于文件系统。你所说的“让它可见”是什么意思还不清楚。在这种情况下,它确实属于数据库,可能是《谢谢你警告我》@JayBlanchard的复制品》
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 2997 05:00:00 GMT");
header("Content-Type: text/html; charset=utf-8");

$id = $_GET['id'];
$row = $conn->query("SELECT usrImg, imgType FROM login WHERE usr='$id'");
$result = $row->fetch_assoc();
if(!empty($result['usrImg'])){
    header("Content-type: image/".$result['imgType']);
    echo $result['usrImg'];
}else{
    header("Content-type: image/png");
    include '../images/no-img.png';
}