【问题标题】:I am trying to fetch image from the database into the modal but the image is not showing in the modal我正在尝试将图像从数据库中提取到模态中,但图像未显示在模态中
【发布时间】:2021-06-15 13:52:20
【问题描述】:

这是我要获取的图像的代码

<img src="pics/file-upload-image-icon-115632290507ftgixivqp.png" id="image_preview1" class="img-thumbnail" style="margin-top: 15px; height:50%; width:20%">

这是我获取数据的控制器代码

$scope.fetch = function(sno) {
            $http.get("form-lab-full-json-fetch.php?sno="+sno).then(ok, notok);
            function ok(resp) {
                $scope.ARRY = resp.data;
            $scope.dept1 = $scope.ARRY[0].dept;
            $scope.uid1= $scope.ARRY[0].uid;
            $scope.uname1 = $scope.ARRY[0].uname;
            $scope.labname1 = $scope.ARRY[0].labname;
            $scope.labinfo1 = $scope.ARRY[0].labinfo;
                alert($scope.ARRY[0].orgname)
            $scope.hdn = $scope.ARRY[0].orgname;
                $scope.images1=$scope.ARRY[0].orgname;
                alert($scope.images1)
                **$scope.image_preview1.attr("src","uploads/"+ARRY[0].orgname);**
            }
                  function notok(resp) {
                alert(resp);
            }
        }

这是预览文件的代码

 function preview_images1(file) {
    if (file.files && file.files[0])
     {
        var reader = new FileReader();
        reader.onload = function (ev) {
            $('#image_preview1').attr('src', ev.target.result);
        }
        reader.readAsDataURL(file.files[0]);
    }

}

【问题讨论】:

    标签: php jquery angular database image


    【解决方案1】:

    这是你的问题吗?在您的控制器中,检查您的查询返回您的图像:

    $scope.image_preview1.attr("src","uploads/"+ARRY[0].orgname);
    

    这个返回什么?

    当您检查返回 this 时,您可以返回到您的模态。您使用框架还是 pur php?要将您的图像返回到模态,您可以使用 AJAX 并在您的标签 img 您的 response.data.image 中设置响应。

    但首先检查您的代码是否返回您的图像,您可以使用

    `print_r($scope.image_preview1.attr("src","uploads/"+ARRY[0].orgname))`
    exit();
    

    【讨论】:

      猜你喜欢
      • 2018-04-16
      • 2018-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      相关资源
      最近更新 更多