generate functionThu, 15 Dec 2022

download image from url, save to '/dalle_images/' and return a full url of the image

function download_image($url){ $extension = pathinfo($url, PATHINFO_EXTENSION); $filename = uniqid() . "." . $extension; $destinationFileName = __DIR__ . '/dalle_images/' . $filename; file_put_contents($destinationFileName, file_get_contents($url)); return '/dalle_images/' . $filename; } download_image(http://url.com/image.png)

Questions about programming?Chat with your personal AI assistant