title: How do I restfully return images using laravel 4?
body: <p>I have a server set up to serve web pages on different domains (specifically a mobile device or localhost:9000 where laravel is serving on localhost:8000).  I'm trying to return image requests on these pages to my laravel server but I'm running into problems.  From a forum post, I thought that setting headers on a request would do the trick but, when I navigate to /api/v1/images/default.jpg, no default cat image is shown.  Instead, I get a box with no image.</p>
  
  <p>Now, the image is in my public folder so if I browse to /public/images/default.jpg I do see my cat image, but I'd rather serve images within my /api/v1/... route.</p>
  
  <pre><code>Route::get('images/{imageName}', function($imageName){
      $img = 'public/images/' . $imageName;
      // return $img;
      echo $img . "\n\n";
      if(File::exists($img)) {
          // return "true";
          // return Response::make($img, 200, array('content-type' =&gt; 'image/jpg'));
          // return Response::download($img, $imageName);
          // Set headers
          header("Cache-Control: public");
          header("Content-Description: File Transfer");
          header("Content-Disposition: inline; filename=\"".$imageName."\"");
          header("Content-Type: image/jpg");
          header("Content-Transfer-Encoding: binary");
          //stream the file out
          readfile($img);
          exit;
      } else {
          return "false";
      }
      return $img;
      // return File::exists($img);
      // return File::isFile('/images/' . $imageName);
      // return $imageName;
      // if(File::isFile('images/' + $imageName)){
      //  return Response::make('images/' + $imageName, 200, array('content-type' =&gt; 'image/jpg'));
      // }
  });
  </code></pre>