title: can't fetch base64 of image created using PHP using fopen and file_get_contents?
body: <p>So, what I want is where user can upload image, a PHP script will add watermark to it,a nd the pic will be hosted on imgur using imgur API</p>
  
  <p>Adding watermark to the image and hosting it to imgur is not the problem, but the problem is: to upload image to imgur, we must pass the base64 of the picture, and I can't fetch the pic that has been given watermark by PHP script using <code>file_get_contents</code> and <code>fopen</code>, it always gives error</p>
  
  <p>Someone please help me with the problem so I can fetch the image, encode it to base64</p>
  
  <p>That's all</p>
  
  <p>UPDATE:</p>
  
  <p>Just to tell you, i used the function to open the PHP file DIRECTLY without saving the pic to disk first, for some reason i can't save the image to the disk, that's why i use imgur</p>
  
  <p>UPDATE AGAIN:</p>
  
  <p>here's my code:</p>
  
  <pre><code>&lt;?php
      header('Content-type: image/png');
      $image = $_GET['url'];
      $imagesize = getimagesize($image);
      $img = imagecreatetruecolor($imagesize[0], $imagesize[1] + 50);
      imagecopy($img, imagecreatefrompng($image), 0, 0, 0, 0, $imagesize[0], $imagesize[1]);
      $string = "Some wild watermarks";
      $font = "font.ttf";
      $fontSize="30";
      $textColor = imagecolorallocate($img, 255,255,255);
      $x=7;
      $y=$imagesize[1] + 42;
      imagettftext($img,$fontSize,0,$x,$y,$textColor,$font,$string);
      imagepng($img);
  ?&gt;
  </code></pre>
  
  <p>Here's the error i got:</p>
  
  <p>Using <code>file_get_contents</code>:</p>
  
  <pre><code>Warning: file_get_contents(watermark.php?url=roughdesign.png) [function.file-get-contents]: failed to open stream: Result too large in URL
  </code></pre>
  
  <p>Using <code>fopen</code>: </p>
  
  <pre><code>Warning: fopen(watermark.php?url=roughdesign.png) [function.fopen]: failed to open stream: Result too large in URL
  Warning: filesize() [function.filesize]: stat failed for URL
  Warning: fread(): supplied argument is not a valid stream resource in URL
  </code></pre>