Support » Plugin: Instant Images - One Click Unsplash Uploads » cURL error – unable to download image to server

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author dcooney

    (@dcooney)

    HI @littlepear,
    As the error message suggests, do you have cURL enabled on the server?

    Yes.

    cURL support enabled
    cURL Information 7.59.0
    Age 4
    Features
    AsynchDNS Yes
    CharConv No
    Debug No
    GSS-Negotiate No
    IDN Yes
    IPv6 Yes
    krb4 No
    Largefile Yes
    libz Yes
    NTLM Yes
    NTLMWB No
    SPNEGO Yes
    SSL Yes
    SSPI Yes
    TLS-SRP No
    HTTP2 Yes
    GSSAPI No
    KERBEROS5 Yes
    UNIX_SOCKETS No
    PSL No
    Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
    Host x86_64-pc-win32
    SSL Version OpenSSL/1.1.0g
    ZLib Version 1.2.11
    libSSH Version libssh2/1.8.0

    Plugin Author dcooney

    (@dcooney)

    Ok thanks, strange because the cURL error only appears if the cURL action fails.
    I’ll try to set up a WAMPServer on a windows machine next week to test.

    I’ve run into this problem as well while using Flywheel for hosting, but tracked down the issue.

    First, in upload.php, I added some error reporting for the cURL operation so I could see what was happening. Near upload.php:75

    $picture = curl_exec($ch);
    if (curl_error($ch)) {
      $response = array(
        'error' => true,
        'msg' => __('cURL error - ' . curl_error($ch), 'instant-images'),
        'path' => '',
        'filename' => ''
      );
      curl_close($ch);
      wp_send_json($response);
      return;
    }

    which gave me: “SSL certificate problem: unable to get local issuer certificate” Which I fixed by adding these lines to your curl options at line 73

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

    Hope this helps others with the same problem!

    • This reply was modified 2 years, 4 months ago by shelkie.
    • This reply was modified 2 years, 4 months ago by shelkie.

    Sorry, goofed in my copying and pasting my previous comment. The curl options to add are:

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    • This reply was modified 2 years, 4 months ago by shelkie.
    Plugin Author dcooney

    (@dcooney)

    Hi @shelkie,
    In 3.2 I added some cURL error handling but yours seems like more a better solution as it relays the cURL error.

    ...
    $picture = curl_exec($ch);
    curl_close($ch);
    // cURL error
    if ($picture === FALSE) {   
       $response = array(
    		'error' => true,
    		'msg' => __('cURL error - Unable to download image to server, please contact your server administrator to enable cURL.', 'instant-images'),
    		'path' => '',
    		'filename' => ''
    	);   
    } 

    I’ve never run into the cURL issue before, but would you recommend adding:

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    to the next release?

    The “SSL certificate problem: unable to get local issuer certificate” error is caused by the CA bundle being out of date on the server. Difficult/impossible to update this sort of thing in a shared hosting environment though.
     
    While turning off VERIFYHOST and VERIFYPEER is not ideal as it diminishes the security of your cURL request, this shouldn’t be an issue as the data being transferred in this case is not sensitive.

    • This reply was modified 2 years, 4 months ago by shelkie.
    • This reply was modified 2 years, 4 months ago by shelkie.
    • This reply was modified 2 years, 4 months ago by shelkie.
    Plugin Author dcooney

    (@dcooney)

    Probably shouldn’t advertise that if it’s so.

    Basically, the user needs permissions to access the REST API.

    I have the same error and it is still there even after changing upload.php as you suggested 🙁

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘cURL error – unable to download image to server’ is closed to new replies.