Some years back, I posted a function to download a remote file with PHP. The function was useful when cURL and other URL/remote file functions had been disabled for security reasons. At the time, cURL on PHP was relatively new and many hosting setups didn’t include the cURL PHP module.
Support for PHP-cURL is pretty standard now, so I thought I’d update the the function to use cURL now. In addition, the function no longer returns a buffer containing the file data which can cause memory issues in PHP when dealing with large files. Pass this updated function a remote URL and local file path and it will download the file and save it to the local path.
This function is useful to retrieve remote images, download HTML pages and download any remote files.
Popularity: 13%
{ 1 comment }