在cakephp中下载Blob文件
我正在使用此查询来获取保存在 mysql 中的介质 blob 中的图像,该图像调用品牌控制器下载功能中的下载功能
SELECT *,CONCAT(\"<img src='../../brands/download/?file_id=\",id,
\"&name=\",logo_name,\"'/>\") AS file
FROM c_brands WHERE merchant_id=" .$merchant_session;
但
function download()
{
//$this->view = 'Media';
Configure::write('debug', 1);
$id = $_GET["file_id"];
$file = $this->Brand->findById($id);
header('Content-type: ' . $file['Brand']['logo_type']);
header('Content-length: ' . $file['Brand']['logo_size']);
header('Content-Disposition: inline; filename='.$file['Brand']['logo_name']);
echo $file['Brand']['logo'];
exit();
}
不知何故,它只是显示图像的占位符。
i am using this query to get image saved in medium blob in mysql which calls download function in brands controller
SELECT *,CONCAT(\"<img src='../../brands/download/?file_id=\",id,
\"&name=\",logo_name,\"'/>\") AS file
FROM c_brands WHERE merchant_id=" .$merchant_session;
DOWN LOAD FUNCTION
function download()
{
//$this->view = 'Media';
Configure::write('debug', 1);
$id = $_GET["file_id"];
$file = $this->Brand->findById($id);
header('Content-type: ' . $file['Brand']['logo_type']);
header('Content-length: ' . $file['Brand']['logo_size']);
header('Content-Disposition: inline; filename='.$file['Brand']['logo_name']);
echo $file['Brand']['logo'];
exit();
}
But somehow it is just displaying the placeholder for image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能解释更多吗?我的意思是,第一个查询(带有 Concat 的查询)和 download() 操作之间的关系是什么,以及您如何使用此查询?另外,我注意到您放置了
你的问题仍然不清楚。
Can you explain more? I mean, what's the relation between the first query (the one with Concat) and the download() action, plus how are you using this query? Also, I notice that you are putting
<img src='../../brands/download/?file_id=\"
, and that relative path is wrong. It must besrc="/brands/download"
.Still, your question is not clear.