时间:2021-07-01 10:21:17 帮助过:3人阅读
Depending on your current php.ini settings, some functions may not work; therefore, let try which function is best for you.
Note: please ensure the folder you want to store the downloaded file is existed and has write permission for everyone or the web process.
For all examples below, I assume that we’re going to download a remote image from: http://4rapiddev.com/wp-includes/images/logo.jpg and save it to a download sub folder with name: file.jpg.
1. PHP Download Remote File With file_get_contents and file_put_contents
Example:
2. PHP Download Remote File With CURL
Example:
3. PHP Download Remote File With fopen
Example:
Again, “download” folder must be exists and writable.
From: http://4rapiddev.com/php/download-image-or-file-from-url/