PHP save picture from url and convert .gif to .png

$picname = 'avatar'.uniqid().uniqid();

$ch = curl_init("https:".$picture->src);
$fp = fopen('/var/www/html/Python/users_avatar/'.$picname.'.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

imagepng(imagecreatefromstring(file_get_contents('/var/www/html/Python/users_avatar/'.$picname.'.gif')), '/var/www/html/topzapp/users_avatar/'.$picname.'.png');

Connect MongoDB to PHP insert and simple query

PHP CODE

$manager = new MongoDB\Driver\Manager("mongodb://127.0.0.1:27017");
var_dump($manager);

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['username' => "ratab",'image' => "b.png",'registerdate' => "21-12-1998"]);

$manager->executeBulkWrite('fcparser.users', $bulk);

var_dump($manager);

$filter = [];
$options = [];

$query = new MongoDB\Driver\Query($filter, $options);
$cursor = $manager->executeQuery('fcparser.users', $query);

foreach ($cursor as $document) {
var_dump($document);
}