php url编码在作为参数发送时仍被读取为url而不是字符串

时间:2014-06-02 22:59:47

标签: php cakephp-2.5

我在webfoot之外有一个文件夹,我正在使用$ this-> response->文件($ path);在里面显示图像。

当我传入文件名时,我的控制器代码工作正常。但我需要将其作为部分URL传递。这就是它破裂的地方。我曾尝试使用urldecode这仍然将其视为网址。

<?php echo ('<img src="books/sendFile/'.rawurlencode("38/backgrounds/orchard-left.png").'" width="100%" alt="aswq" />') ?>

输出为books / sendFile / 38%2Fbackgrounds%2Forchard-left.png但浏览器仍将其视为books / sendFile / 38 / backgrounds / orchard-left.png

我的控制器

public function sendFile($file) {
    $file = rawurldecode($file);
    $path = ROOT.DS.'bookUploads'.DS.'Users'.DS.'ingemit/Books/'.$file;
    $this->response->file($path);
    return $this->response;
} 

0 个答案:

没有答案
相关问题