Component for downloading images by URL
This is component for downloading images by URL from another servers. This component uses cURL PHP library., (*1)
The preferred way to install the component is through composer., (*3)
Either run, (*4)
composer require greeflas/php-image-downloader
or add, (*5)
"greeflas/php-image-downloader": "dev-master"
to the require section of your composer.json., (*6)
Create component instance, (*7)
$downloader = new \greeflas\tools\ImageDownloader([ 'class' => \greeflas\tools\validators\ImageValidator::class ]);
in array you should specify the validator class. It used for validation of downloaded files.
If you don't want run validation, you can use a \greeflas\tools\validators\FakeValidator::class
., (*8)
Then you should call method for downloading, (*9)
$downloader->download($url, $imagesRoot, $fileName);
this method takes as agruments: URL to image, path to catalog where file will be saved and name for downloaded file., (*10)