Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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
无法在我的live环境中的PHP中显示MySQL中的图像blob,在开发环境中工作_Php_Mysql_Image - Fatal编程技术网

无法在我的live环境中的PHP中显示MySQL中的图像blob,在开发环境中工作

无法在我的live环境中的PHP中显示MySQL中的图像blob,在开发环境中工作,php,mysql,image,Php,Mysql,Image,我无法在我的实时托管环境中显示MySQL中的blob图像,它可以在开发环境中工作。 我有一个getimage.php文件,我将图像的id传递给该文件,我不会在页面上写出任何文本。 这两种方法在我的开发环境中都非常有效。 简单代码: 方法1: 方法2: 我没有收到php错误,我收到以下错误: 无法显示图像“0”,因为它包含错误` 如果我在实时环境中硬编码imagepath,它可以正常工作: header("Content-type: image/jpeg"); $data = file_get_c

我无法在我的实时托管环境中显示MySQL中的blob图像,它可以在开发环境中工作。 我有一个getimage.php文件,我将图像的id传递给该文件,我不会在页面上写出任何文本。
这两种方法在我的开发环境中都非常有效。
简单代码:

方法1: 方法2: 我没有收到php错误,我收到以下错误:

无法显示图像“0”,因为它包含错误`

如果我在实时环境中硬编码imagepath,它可以正常工作:

header("Content-type: image/jpeg");
$data = file_get_contents("../images/sunflowers.jpg");
echo $data;

任何帮助都将不胜感激

将标题行进一步下移,以便php错误可以以文本形式发送

$data = mysql_result($result, 0,'documentfile');
header("Content-type: image/jpeg");
echo $data;
这样您就可以读取错误, 您也可以尝试保存图像并在文本编辑器中打开它,
或者只需使用浏览器查看源代码,我发现这与从Dev上传到Live的数据库有关,可能是编码之类的。当我将图像文件重新上传到Live DB时,它们显示正确。

我向下移动了标题,现在得到了一个损坏的图像。当图像blob被转换为imag时e、 它是否临时存储在硬盘上?可能是权限问题吗?如果您不希望得到更好的答案,请接受您的答案。单击答案左侧的勾号。(或者如果对您更有帮助,请接受@PugganSe的答案…)
header("Content-type: image/jpeg");
$data = file_get_contents("../images/sunflowers.jpg");
echo $data;
$data = mysql_result($result, 0,'documentfile');
header("Content-type: image/jpeg");
echo $data;