PHP Download Image Or File From URL
程序员文章站
2022-05-17 15:19:17
...
I’ll show you 3 functions that download a particular file (ex: image,video,zip,pdf,doc,xls,etc) from a remote resource (via a valid URL) then save to your server.
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/
推荐阅读
-
C# extract img url from web content then download the img
-
C# WebClient download image within url and display the downloaded picture automatically in windows os
-
PHP Download Image Or File From URL
-
C# extract img url from web content then download the img
-
Java – How to download a file from the Internet
-
Java – How to download a file from the Internet
-
How to download file from URL in java
-
php制作图片验证码echo $url和echo file_get_content($url)的区别
-
PHP Download Image Or File From URL
-
C# WebClient download image within url and display the downloaded picture automatically in windows os