Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我找不到&;显示从MYsql到表列的图像_Php_Mysql_Image - Fatal编程技术网

Php 我找不到&;显示从MYsql到表列的图像

Php 我找不到&;显示从MYsql到表列的图像,php,mysql,image,Php,Mysql,Image,下面是我的表格和代码 Table_gnews | +-------------------+ | gnewsid=>int | | gnewsh=>varchar | | gnewsd=>varchar | | gnewsimg=>longblob| <table id="exampleN" class="display table table-striped table-bordered nowrap dt-

下面是我的表格和代码

Table_gnews |
+-------------------+
| gnewsid=>int      |                
| gnewsh=>varchar   | 
| gnewsd=>varchar   | 
| gnewsimg=>longblob|

<table id="exampleN" class="display table table-striped table-bordered nowrap dt-responsive" style="font-size: smaller;">
 <thead>
   <tr>                         
     <th style="background-color:lightcoral;">Image</th>
     <th style="background-color:lightgray;">Date</th>
     <th style="background-color:lightgray;">News HeadLines</th>
     <th style="background-color:lightgray;">News Details</th>  
   </tr>
   </thead>                 
   <tbody>
    <?php if (count($data5)): ?>
    <?php foreach ($data5 as $key => $row4): ?> 
   <tr>
    <td><img src="data:image/png;base64,'.base64_encode"><?php echo   $row4['gnewsimg']; ?></td>
    <td><?php echo $row4['gnewsdate']; ?></td>
    <td><?php echo $row4['gnewsh']; ?></td>
  </tr>                     
    <?php endforeach; ?>
    <?php endif; ?>
</tbody>
</table>  
表格|
+-------------------+
|gnewsid=>int|
|gnewsh=>varchar |
|gnewsd=>varchar |
|gnewsimg=>longblob|
形象
日期
新闻标题
新闻详情
**现在我一个接一个地插入图像,但这非常耗时

我的计划是:我将所有图像存储在我的网站服务器中,而不是存储在MySQL数据库中,因为我不想不必要地增加数据库大小,并在数据库中保留对该文件的引用** **例如: 我的图片在服务器上,比如www/images/logo/,还有像l1.jpg、l2.jpg等图片

我想在我的SQL数据库中创建一个varchar字段,该字段包含唯一的文件名,并在我的网站上显示图像


我将如何做?

请尝试下面的图片

echo ' <img src="data:image/png;base64,'.base64_encode( $row4['gnewsimg'] ).'"/>';
echo';

图像值添加到src属性之外。请提供更多详细信息您是将图像的物理路径保存在DB中,还是将图像编码在base64中,然后保存在DB中?能否提供更多详细信息?我将图像保存到桌面并上传到MySQL。我的代码有什么问题吗?为什么不直接存储在文件夹中?如果存储在db中,你需要一个非常强大的服务器来处理它,如果你在wwwI中运行,如果你没有问题的话,我有一个问题要回答。问题是:我将如何将批量图像上传到MYSQL数据库。我现在正在一个接一个地做