简体   繁体   English

Lamp / Cakephp:流式传输图像:二进制0x00替换为0x20

[英]Lamp / Cakephp: Streaming an image : Binary 0x00 replaced by 0x20

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

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. 但是我遇到的问题是,当显示图像时,所有Null(0x00)都被替换为0x20,我不知道为什么。 The data in the database shows it being nulls but somewhere along the way it gets changed to 0x20s. 数据库中的数据显示它为空,但在此过程中某处被更改为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. 我可以转储二进制内容出来,还没有被篡改。

Something with the stack or cakephp any thoughts? 对堆栈或cakephp有什么想法吗?

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? 更新:我注意到流的开头已经有一个空格,我试图对其进行跟踪,这可能是问题吗?

Yeah, something along the way is freaking out (because OMG nulls, what if something thinks they're string terminators) and replacing them with spaces. 是的,此过程中出现了一些问题(因为OMG为null,如果有人认为它们是字符串终止符,该怎么办),然后将它们替换为空格。 I suspect CakePHP but am not quite certain enough to say j'accuse. 我怀疑CakePHP,但不确定是否可以说出j'accuse。 Try: 尝试:

header('Transfer-Encoding-Type: base64');

and see if that convinces whatever's doing it to leave your data alone. 并查看是否可以说服您进行任何操作以让您的数据保持独立。

我在文件的某个地方有一个杂乱的空间,要追踪很有趣:)我猜想这会切换堆栈中某些内容的模式并破坏文件

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

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