How to Download image from url Php ?

This is the Easiest Way to How to Download image from url Php ? at KTechBlog.com. This is the Sample code for Download image from URL using PHP ?, Download and Save image using URL on your server with PHP, Php Save Image From Url,How to Force Download FIle in PHp and How to Download image from url Php ?

<?php

$url_to_image = "https://cdn.britannica.com/77/170477-004-B774BDDF.jpg";
$my_save_dir = 'images/';
$filename = basename($url_to_image);
$complete_save_loc = $my_save_dir.$filename;

file_put_contents($complete_save_loc,file_get_contents($url_to_image));
?>

In this Code $url_to_image is the Url of Your Image.
In this Code $my_save_dir is Path Where Image Will Download.
$filname is Image File Name
$complete_save_loc is the Full path With Image Name

file_put_contents is the Php inbuilt Function to Download the File, First parameter is the Your File Save Location and Second is the path of url File.
For More Detail Watch this Video

Leave a Reply

Your email address will not be published. Required fields are marked *