Download image using php from protected server

If you want to download image from a website where allow_url_fopen set to false or some other protection applied then you can’t download it with file_put_content() or copy() etc. Using curl and behaving like a user agent can be used to download image to local directory.