Ronaldo Cristover
Ronaldo Cristover

Reputation: 338

Cannot Upload File with Curl PHP (OSX to Windows Server)

I have some problem here,

I have code that have function to upload images to remove server using CURL PHP. But I have a problem. 1. I cant send files with curl from my OSX MAMP to XAMPP Windows, or XAMPP WIndows to OSX MAMP.

this is my snippet code

    $path = 'uploads/';
    $ext = pathinfo($path.$imagesName, PATHINFO_EXTENSION);
    $ch = curl_init();
    $cfile = new CURLFile($path.$imagesName,$ext,$imagesName);
    $data = array("image" => $cfile);
    $url = $this->ocDomain . '/index.php?route=api/custom/uploadImage';
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    Log::info('Curl Image URL : ' . $url);
    $response = curl_exec($ch);

anyone have a clue, how and why this can be happen?

please give me a clue guys

Upvotes: 1

Views: 67

Answers (1)

CatalinB
CatalinB

Reputation: 581

if($errno = curl_errno($ch)) {
    $error_message = curl_strerror($errno);
    echo "cURL error ({$errno}):\n {$error_message}";
}

add this to see if is any error

Upvotes: 1

Related Questions