开发者

downloading Blob file in cakephp

开发者 https://www.devze.com 2023-02-18 06:05 出处:网络
i am using this query to get image saved in medium blob in mysql which calls download function in brands controller

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 j开发者_JS百科ust displaying the placeholder for image.


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 be src="/brands/download".

Still, your question is not clear.

0

精彩评论

暂无评论...
验证码 换一张
取 消