title: Upload image to telegra.ph with PHP
body: <p>I don't know the Python language. Can someone help me understand whether I correctly converted this to PHP? I want to upload a file to <a href="http://telegra.ph" rel="nofollow noreferrer">http://telegra.ph</a> with PHP, but I don't know how to upload from PHP.</p>
  
  <p>This code is an example from a <a href="https://github.com/python273/telegraph/issues/3" rel="nofollow noreferrer">Python Telegraph API wrapper library</a>:</p>
  
  <pre><code>import requests
  
  with open('/Users/python273/Desktop/123345.jpeg', 'rb') as f:
      print(
          requests.post(
              'http://telegra.ph/upload',
              files={'file': ('file', f, 'image/jpeg')}  # image/gif, image/jpeg, image/jpg, image/png, video/mp4
          ).json()
      )
  </code></pre>
  
  <p>And this is my PHP code that doesn't work. Is there something wrong?</p>
  
  <pre><code>$url = 'http://example.com/image.jpg';
  $img = 'http://telegra.ph/upload/';
  $ch = curl_init($url);
  $fp = fopen($img, 'wb');
  curl_setopt($ch, CURLOPT_FILE, $fp);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_exec($ch);
  curl_close($ch);
  fclose($fp);
  </code></pre>
  
  <p>When I run this code, I see the following error:</p>
  
  <blockquote>
    <p>Warning: copy(telegra.ph/upload): failed to open stream: HTTP wrapper does not support writeable connections</p>
  </blockquote>