So my last question was on how to have my techID shown from a search :

我的最后一个问题是如何从搜索中显示我的techID

I am trying to have my "Details" page to reference two seperate parts of my server that are linked via techID

我正在尝试使用我的“Details”页面来引用我的服务器的两个独立部分,这些部分通过techID链接

My new question is still on this page. I have added in an echo image as well. but am having trouble using Blob and having it display my image and not binary JPEG data. I've been trying to find another instance of this but cannot find any that fix my error.

我的新问题还在这一页上。我还添加了一个回波图像。但是我在使用Blob和让它显示我的图像而不是二进制JPEG数据时遇到了麻烦。我一直在尝试寻找另一个实例,但是找不到任何可以修复我的错误的实例。

//Header ('Content-type: image/jpeg')
echo "<dt><strong>Technician Image:</strong></dt><dd>" . '<img src='.$row2['image'].' width="290" height="290">' . "</dd>";

and

$query_Recordset2 = "SELECT * FROM technician WHERE techID=" . $row1["techID"] ;
$Rs2 = mysql_query($query_Recordset2) or die(mysql_error());

Are the only changes I have put in so far from my last question (obviously including the fix I was given that worked).

到目前为止,我所做的所有更改都与我的上一个问题(显然包括我得到的已生效的修复)相去甚远。

What I do not understand is where and how to put 'Content-type: image/jpeg' to have my page recognize the image being linked is it's MIME TYPE image/jpeg.

我不明白的是,在哪里以及如何放置“Content-type: image/jpeg”来让我的页面识别正在链接的图像,它是MIME类型的image/jpeg。

What I am seeing on my page is this

我在我的页面上看到的是这个

Technician Image: �E��j��i`=7f$D��o"�������b���Ckkc��R��^M�;n~��0&m)J��R��E)JDR��E)JDR��E)JDR��E)JDR��E)JDR��E)JDSjR��)���+��N��.R,u����i��n9,���QX~ ����{(����̮�:���2�12��"��aV7�6���{���LP[�W�����گ� R$+� ��LMc'hM�5�o�PA����|���ګ���.8��E��ģ��Rn ��1�[��{��3>�rY��X�ۜ;�Ǖ����u���z��'�vf�N葟 ��z�Q�����k��3���O��ܨ�ۀ�?S���,N� �����[{+D� �;�'�$�$�&�iJR��)JR��)JR��)JR��)JR��)JR��)JR��)JR��)JR��)JR��)JR��)JR��)�� width="290" height="290">

j E技术员形象:�����我' = 7 f $ D��o”�������b���Ckkc��R���^米;n ~��0 a&m)j��R��E)JDR��E)JDR��E)JDR��E)JDR��E)JDR��E)JDSjR��)���+��n��。R u����我��n9,���QX ~����{(����̮�:���2�12��“��aV7�6���{���LP(W������گ�R美元+���LMc 'hM�5�o�PA����|���ګ���。Rn E 8����ģ����1�[��{��3 >�一���Xۜ;�Ǖ����你���z��’�vf N葟���z Q������k��3���O��ܨ�ۀ�?年代���,������[{ + D��,�’���美元&�iJR��)小��)小��)小��)小��)小��)小��)小��)小��)小��)小��)小��)��宽度= " 290 "高度= " 290 " >

Obviously I have deleted a middle chunk so it's not massive. there is a little "Broken image" box that appears infront and when I right click and choose "Open image in new window" the URL it puts in is simply Content-type: or I get a forbidden access page with the url http:// localhost/Sim5Server/Pages/%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%10JFIF%EF%BF%BD%01%02%EF%BF%BD%EF%BF%BDd%EF%BF%BDd%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BDC%EF%BF%BD

很明显,我已经删除了一个中间块,所以它并不大。

I have put a space in that url since it is not a link for the internet.

我在那个url中放了一个空格,因为它不是互联网的链接。

I have only used normal BLOB type as I just need it as a small less than 64Kb image

我只使用普通的BLOB类型,因为我只需要它作为一个小于64Kb的小图像

4 个解决方案

#1


38

In your current case, you have two upfront options.

在目前的情况下,您有两个预先选择。

The first, and the one I don't recommend if you have numerous images like this, is to use inline base64 encoding. This is done with:

如果您有很多这样的图片,我不建议您使用内联base64编码。这是完成:

<img src="data:image/jpeg;base64,<?php echo base64_encode($image); ?>" />

A copy/paste version, using your existing code:

复制/粘贴版本,使用现有代码:

echo '<dt><strong>Technician Image:</strong></dt><dd>'
     . '<img src="data:image/jpeg;base64,' . base64_encode($row2['image']) . '" width="290" height="290">'
     . '</dd>';

The second method is to create an "image" PHP file that takes the ID of the image in the database as a query-string parameter and outputs the image. So, your HTML would look something like:

第二种方法是创建一个“image”PHP文件,该文件将数据库中图像的ID作为查询字符串参数并输出图像。所以,您的HTML应该是这样的:

<img src="image.php?id=<?php echo $image_id; ?>" />

And your PHP page would look something similar to:

你的PHP页面看起来就像:

<?php
$id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? intval($_GET['id']) : 0;
$image = getImageFromDatabase($id); // your code to fetch the image

header('Content-Type: image/jpeg');
echo $image;
?>

更多相关文章

  1. InnoDB辅助索引页面的物理结构是什么样子的
  2. 如何使用mysql在php文件夹中快速更改图像名称?
  3. MySQL内核解析:Innodb页面存储结构-1
  4. 视差滚动与图像仅通过徽标透明度
  5. 有没有办法阻止使用类似Firebug的工具在页面中编辑HTML和CSS内容
  6. 与同一页面上的两个jquery datepickers冲突
  7. 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什
  8. iframe操作、调用父页面元素或js函数
  9. 图片在页面内随意飘动,遇到边界还会反弹

随机推荐

  1. 亲试,Windows平台上使用Qt5.2.1编写Androi
  2. 【Android Api 翻译1】Android Texting(2)T
  3. 史上最全!押题率90%的 Android(安卓)中高
  4. Android(安卓)colors.xml (颜色大全)
  5. Android Activity去除标题栏和状态栏
  6. android摄像头采集和预览-第二种方法
  7. android textView加边框
  8. xarmain使用Forms编译android工程出现sup
  9. 2013.04.03——— android 图片缓存之二L
  10. Android(安卓)AbsListView