Lamp/Cakephp:流式传输图像:二进制0x00替换为0x20 [英] Lamp / Cakephp: Streaming an image : Binary 0x00 replaced by 0x20

查看:123
本文介绍了Lamp/Cakephp:流式传输图像:二进制0x00替换为0x20的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个脚本,将图像从数据库中拉出并显示给用户,由<img src="viewImage/someImageName">

I'm trying to create a script that pulls an image out of the database and displays it to the user, called by <img src="viewImage/someImageName">

但是我遇到的问题是,当显示图像时,所有Null(0x00)都被替换为0x20,我不知道为什么.数据库中的数据显示为空,但在此期间将其更改为0x20s.

But the problem I'm having is when the image is displayed all of the Nulls (0x00) are replaced by 0x20 and I have no idea why. The data in the database shows it being nulls but somewhere along the way it gets changed to 0x20s.

有人有什么主意吗?有什么我想念的吗?

Does anyone have any idea? is there something I'm missing?

这是我正在使用的代码:

Here is the code I'm using:

$data = $this->Image->read(NULL, $userId);
header("Content-Type: image/jpeg");
echo($data['image']);
die;

我认为这与代码无关,因为如您所见,这里没有出错的地方.我可以将二进制内容转储出去,但尚未被篡改.

I don't think it has anything to do with the code because as you can see there is no place for error. I can dump the binary contents out and it has not yet been tampered.

与堆栈或cakephp有关的任何想法?

Something with the stack or cakephp any thoughts?

更新: 我注意到在流的开头有一个空格,我试图对其进行跟踪,这可能是问题所在吗?

Update: I've noticed that a space is making to the beginning of stream, I'm trying to track it down, could this be the problem?

推荐答案

我在文件中的某个地方有一个杂散空间,可以找到很多乐趣:) 我猜这会切换堆栈中某些内容的模式并破坏文件

I had a stray space in a file somewhere, lots of fun to track down :) I guess this switches the mode of something in the stack and corrupts the files

这篇关于Lamp/Cakephp:流式传输图像:二进制0x00替换为0x20的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆