title: Using imgur api v3 to upload images with php
body: <p>I'm trying to write a very simple test to upload an image to imgur and then redirect to the imgur page once it's done. (haven't gotten to that point yet)</p>
  
  <p>I've looked all around these forums and tried so many different codes posted here, as well as cobbled some together from various posts. Finally, I've stopped getting errors in the php. </p>
  
  <p>But.. in every code I've seen, it displays the image once it's done. Using that exact same code, my image does not appear, all I get is a page with Result: and nothing more. Does anyone have any idea what could be the problem?</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
    &lt;form action="upload_img.php" method="post" enctype="multipart/form-data"&gt;
          &lt;input type="file" name="imgupload" /&gt;&lt;br&gt;
          &lt;input type="submit" value="Upload to Imgur" /&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the php file:</p>
  
  <pre><code>&lt;?php
  
      $client_id = '$clientIDHERE';
  
          $file = file_get_contents($_FILES["imgupload"]["tmp_name"]);
  
          $url = 'https://api.imgur.com/3/image.json';
          $headers = array("Authorization: Client-ID $client_id");
          $pvars = array('image' =&gt; base64_encode($file));
  
          $curl = curl_init();
  
          curl_setopt_array($curl, array(
             CURLOPT_URL=&gt; $url,
             CURLOPT_TIMEOUT =&gt; 30,
             CURLOPT_POST =&gt; 1,
             CURLOPT_RETURNTRANSFER =&gt; 1,
             CURLOPT_HTTPHEADER =&gt; $headers,
             CURLOPT_POSTFIELDS =&gt; $pvars
          ));
  
          $json_returned = curl_exec($curl); // blank response
          echo "Result: " . $json_returned ;
  
          curl_close ($curl); 
  
  ?&gt;
  </code></pre>