2
    $image = file_get_contents($_FILES['upload']['tmp_name']);
    $id = 'myid';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $id));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => base64_encode($image) ));
    $response = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($response);

これは、imgur に匿名で画像をアップロードするために必要な引用のブロックです。Mac OS マシンの xampp では動作しますが、Windows の xampp では動作しません。Windows xamppのcurlについて次のことも知っています:

-it is enabled
-it works when i try to grab the content of an url
-it doesnt work when i try to make DELETE request to remove an anonymous image(the same code works on the mac os xampp)

2 台のコンピューターの cURL 設定にはいくつかの違いがあると考えました。方法を教えていただけるとありがたいです!前もって感謝します。

4

1 に答える 1