title: Resizing image in php after file_get_contents
body: <p>Can anybody tell me how I can solve the following issue:</p>
  
  <pre><code>include('php/resizeImage.php');
  
  if($_POST['uploadlink']){
      $url = $_POST['uploadlink'];
      $urlImage = file_get_contents($url);
  
      if ($_POST['filename']){
          $filename = $_POST['filename'].".jpg";
      } else {
          $urlinfo = parse_url($url);
          $filename = basename($urlinfo['path']);
      }
  
      $image = new ResizeImage();
      $image-&gt;load($filename);
      $image-&gt;resizeToWidth(300);
      $image-&gt;save($filename);
  
      file_put_contents("images/upload/".$filename, $urlImage);
  
    }
  </code></pre>
  
  <p>After I have received the image data from file_get_contents from a URL I want to resize it through my resizeImage script which takes the filename of the image as a parameter.</p>
  
  <p>Edit: ResizeImage function load and resizeToWidth:</p>
  
  <pre><code>function load($filename) {
  
        $image_info = getimagesize($filename);
        $this-&gt;image_type = $image_info[2];
        if( $this-&gt;image_type == IMAGETYPE_JPEG ) {
  
           $this-&gt;image = imagecreatefromjpeg($filename);
        } elseif( $this-&gt;image_type == IMAGETYPE_GIF ) {
  
           $this-&gt;image = imagecreatefromgif($filename);
        } elseif( $this-&gt;image_type == IMAGETYPE_PNG ) {
  
           $this-&gt;image = imagecreatefrompng($filename);
        }
     }
  
  function resizeToWidth($width) {
        $ratio = $width / $this-&gt;getWidth();
        $height = $this-&gt;getheight() * $ratio;
        $this-&gt;resize($width,$height);
     }
  </code></pre>
  
  <p>I have no trouble doing it when the user selects a local image through input type='file'.</p>
  
  <pre><code>    if (isset($_FILES["uploadedfile"])){
          $ufilename = $_FILES["uploadedfile"]["name"];
          $ufiletmpname = $_FILES["uploadedfile"]["tmp_name"];
  
          $image = new ResizeImage();
          $image-&gt;load($ufiletmpname);
          $image-&gt;resizeToWidth(300);
          $image-&gt;save($ufiletmpname);
  }
  </code></pre>
  
  <p>Another problem:
  I forward the name of the user to my script because I want to create an individual folder for each user, so they only can see their own uploaded images. </p>
  
  <pre><code>$admin = $_GET['admin'];
  file_put_contents("images/upload/".$admin."/".$filename, $urlImage);
  </code></pre>
  
  <p>Why is this not working for me?</p>
  
  <p>Thanks.</p>