0

I have a folder outside of the webfoot and I am using the $this->response->file($path); to display the images inside.

My controller code works fine when I just pass in the file name. But I need to pass it in as a part URL. This is where it breaks. I have tried to use urldecode this still sees it as a url.

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

It is outputted as books/sendFile/38%2Fbackgrounds%2Forchard-left.png but the browser still sees it as books/sendFile/38/backgrounds/orchard-left.png

my controller

public function sendFile($file) {
    $file = rawurldecode($file);
    $path = ROOT.DS.'bookUploads'.DS.'Users'.DS.'ingemit/Books/'.$file;
    $this->response->file($path);
    return $this->response;
} 
Keith Power
  • 13,891
  • 22
  • 66
  • 135
  • Try and var_dump the $file variable after decoding it. – Jacer Omri Jun 03 '14 at 00:41
  • I don't think the decode gets called it is looking for the url books/sendFile/38/backgrounds/orchard-left.png It should only be looking for books/sendFile/ and passing books/sendFile/38/backgrounds/orchard-left.png – Keith Power Jun 03 '14 at 08:07

0 Answers0