title: Download remote file using laravel
body: <p>I've a link that gets the image, but the image has been removed, renamed or moved to another place</p>
  
  <pre><code>public function index()
  {    
      $array = [
           { image:'https://imgimob.sobressai.com.br/fotos/765/475139/12768822_g.jpg' },
           { image:'http://imgimob.sobressai.com.br/fotos/765/475140/12768824_g.jpg' }
      ]    
      for ($i = 0; $i &lt; count($array); $i++) {
         if(!$contents = file_get_contents($array[$i]['image'])) 
         {
               return 'Not found!';
         else {
          Storage::disk('public')-&gt;put('default/teste.jpg', $contents); 
         } 
     }
  }
  </code></pre>
  
  <p>if the image no exist then I get this error</p>
  
  <p><code>file_get_contents(http://imgimob.sobressai.com.br/fotos/765/475140/12768824_g.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found</code></p>
  
  <p>I would link get to return "doesnt' exist" and download file if it does.</p>