generate functionThu, 15 Dec 2022

get image from url, save it to disk and return a url of the image

function getImage($url) { $path = "upload/"; $filename = md5($url) . '.jpg'; if (!file_exists($path . $filename)) { $image = file_get_contents($url); if ($image !== false) { file_put_contents($path . $filename, $image); } } return $path . $filename; }

Questions about programming?Chat with your personal AI assistant