V
V
Vasya2020-04-23 18:11:06
PHP
Vasya, 2020-04-23 18:11:06

Is there any way to upload an image to the server by URL?

$image = 'https://habrastorage.org/r/w60/webt/5c/96/7e/5c967eb0d3dc2313190956.gif';
$image1 = 'https://habrastorage.org/r/w60/files/fd5/543/b46/fd5543b46ea3495fba32ad98a9900062.jpg';
$ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $fred);//адрес сервера 
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => new CurlFile($image)));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $res0 = json_decode(curl_exec($ch));
            curl_close($ch);

Can't load 2 images via url. How can this be done?
Thanks to

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question