title: trying to save an image with its name intact php
body: <p>Hi i am using the script below to save an image FROM another domain into my own domain.</p>
  
  <pre><code>  //get image name and extension
    $img = 'http://otherdomain.com/image/123.jpg';
    $getname = explode('/', $img);
    $thumbname = $getname[count($getname) - 1];
    //save the image file
    $file = file_get_contents($img);
    $path = 'thumbs/'+ $thumbname;
    file_put_contents($path, $file);
  </code></pre>
  
  <p>But i cant get this to work. the $path resulted in <code>123</code> but not <code>123.jpg</code>(which i need).
  and am i doing the file get content and file put content right?</p>