简体   繁体   English

查看以blob数据类型的形式从数据库收到的图像到php中的新页面

[英]viewing an image recieved from database in form of an blob datatype to a new page in php

I have made an code which is used to receive image from database and it's working perfectly. 我已经编写了一个用于从数据库接收图像的代码,它工作正常。 But now as user click's on the image it should be opened on a new page,and i have tried few thing but it's not working... 但是现在当用户单击图像时,应该在新页面上打开它,我已经尝试了几件事,但是它不起作用...

the below code id used to display the image 下面的代码ID,用于显示图片

  $query=mysqli_query($conn,"select * from images") or die("unable to 
       connect");




$i=1;
                while($row=mysqli_fetch_array($query,MYSQLI_BOTH))
                    {
                    //echo '<img id="my" height="150" width="320" src="data:image;base64,'.$row['image'].'  "> ';
                    echo '
                    <tr>

                    <t>'.@$row["id"].'</td>
                    <a target="_blank" href="09.jpg">
                    <img height="150" width="150" src="data:image/jpeg;base64,'.base64_encode( $row['image'] ).'"/>

                    <td><a href="delete1.php?id='. $row['id'] .'">x</a></td>
                    </td>

        ';

            $i++;


                            }   


                ?>

Now here i want is when user click's on the image , a new page will show an enlarged image... 现在我想要的是当用户单击图像时,新页面将显示一个放大的图像...

Don't save image in database, save it as file in server then save the file name into database 不要将图像保存在数据库中,而是将其另存为服务器中的文件,然后将文件名保存到数据库中

You must be save image as two sizes, small and normal, the smal for display in table, when the user click on image, go to normal image 您必须将图像保存为两种尺寸,小号和普通号,用于在表格中显示的小号,当用户单击图像时,转到普通图像

You can save one name in database, example (img1.jpg) And in images directory save (sm-img1.jpg) and (img1.jpg) 您可以在数据库中保存一个名称,例如(img1.jpg),在图像目录中保存(sm-img1.jpg)和(img1.jpg)

The code 编码

<a href="url/mydirectory/$row['image']" target="_blank">
<img width="150" height="150"  src="url/mydirectory/sm-$row['image']" />
</a>

Or 要么

<img width="150" height="150"  src="url/mydirectory/sm-$row['image']" onclick="window.open('url/mydirectory/$row['image']', '_blank');" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM