doubiao9775 2010-06-15 19:02
浏览 27

php blob以1脚本中的joomla模块中的图片

I have pictures in a database and i want to read it out and display it as a picture. However i get strange long charakters as result.

my code:

<?php
/**
* @version 1.0 $
* @package HelloWorld
* @copyright (C) 2010 BlaBlbb
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
 // assemble query
$query = '
    SELECT *
    FROM artikel
';

$database->setQuery($query);
if ( !$database->query() ) {
echo "<script type='text/javascript'>
         alert('".$database->getErrorMsg()."');
      </script>";
} else {
$rows = $database->loadObjectList();
}
echo '<table>';
foreach ($rows as $rowi)
{

echo '<tr><td>'.$rowi->Artikelname.'</td>';
echo '<td>'.$rowi->Stueckpreis.'</td>';
echo '<td>'.$rowi->Gewicht.'</td>';
echo '<td>'.$rowi->Lagerstand.'</td>';
echo '<td>'.$rowi->Aenderungsdatum.'</td>';
echo '<td><img>'
.$rowi->Foto.
echo'</img></td></tr>';


}
echo '</table>';
?>
<!--<h1>Hallo Welt</h1>
<p>Das ist ein Test</p>
<p>juhuu</p>
-->

any suggestions? i wanna have the image in the same file if possible... i am very new to joomla so i dont know how to use it with a second php that creates the picture...

  • 写回答

1条回答 默认 最新

  • dongqian3198 2010-06-15 19:24
    关注

    You're seeing strange characters because you're just echoing the raw image data into the page. In order to serve an image, the browser must request it as a file from the server*.

    This means that you need to either need to:

    1. write your image data to disk, then give the browser the URL to the file in the <img> tag, or
    2. you need to create a script that returns the proper Content-type header for the image type and echos the image data then give the browser the URL to the script in the <img> tag.

    *: (Yes, there's data:, but that's not a suitable solution for most cases. Especially this one.)

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line