private function Photo($src){ $name = "/var/www/www-root/data/www/sat.ru/loadfiles/moduls/doska/smallfoto/d5eeb06e92530347844c74db2188c139.jpg"; $ch = curl_init($this->getServer()); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_POSTFIELDS, ['photo' => new \CurlFile($name, 'image/jpeg', 'd5eeb06e92530347844c74db2188c139')]); $response = curl_exec( $ch ); curl_close( $ch ); var_dump($response); return json_decode($response); } 

getting output

 string(72) "{"server":840729,"photo":"[]","hash":"faf82b1faa72913f733b8b482f8bfe25"}" 

What could be the problem ?

    1 answer 1

    Forgot to specify the file extension in the name. This is how it works:

     curl_setopt($ch, CURLOPT_POSTFIELDS, ['photo' => new \CurlFile($name, 'image/jpeg', 'd5eeb06e92530347844c74db2188c139.jpg')]);