I'll show you 3 functions this download a particular file (EX:IMAGE,VIDEO,ZIP,PDF,DOC,XLS,ETC) from a remote resource (vi A valid URL) then save to your server.
Depending on your current php.ini settings, some functions; Therefore, let-try which function is best for you.
Note:please ensure the folder you want to store the downloaded file is existed and have write permission for everyone or T He web process.
For all examples below, I assume this 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/