【发布时间】:2019-01-26 08:47:57
【问题描述】:
我的网址看起来像 ..../image/view?id=6
导航到这个 url 应该会给出我数据库中的图像。 但目前我收到了一堆奇怪的字符作为回应。
当我输出(见下文)时,我看到了我的图像。
<img src="data:image/jpeg;base64,'.base64_encode( $image->Data ).'"/>
我正在使用这段代码来生成我的 HTTP 响应,但响应只是 blob 数据:
header('Content-Type :'.$image->Extension);
header('Content-Disposition: filename='.$image->Name.'.'.$image->Extension);
header('Content-Length: ' . strlen($image->Data));
$response->format = Response::FORMAT_RAW;
$response->data = $image->Data;
当前输出开始于:
����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality ��C $.' ",#(7),01444'9=82<.342��C 2!!22222222222222222222222222222222222222222222222222���"�� ���}!1AQa"q2���#B��R��$3br�
使用的标题:
Accept-Ranges: bytes
Cache-Control: private
Content-Disposition: inline; filename="FYdsl67l4PWJQ7QFFeo14Ena76gr0pEP.jpg"
Content-Length: 320135
Content-Type: image/jpeg
Date: Mon, 28 Jan 2019 19:05:11 GMT
Expires: 0
Pragma: public
Server: Microsoft-IIS/8.5
X-Powered-By: PHP/5.6.24, ASP.NET
任何帮助将不胜感激
【问题讨论】:
-
检查您的内容类型标题。有关更多详细信息,请查看此stackoverflow.com/questions/2633908/…
-
感谢您的建议,但不幸的是,结果仍然相同。我的标题现在是:prntscr.com/mcehqy