greeflas / php-image-downloader
Component for downloading images by URL
Installs: 27 479
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 4
Open Issues: 0
Requires
- php: >=5.6
- ext-curl: *
This package is auto-updated.
Last update: 2024-11-16 02:57:02 UTC
README
This is component for downloading images by URL from another servers. This component uses cURL PHP library.
Installation
The preferred way to install the component is through composer.
Either run
composer require greeflas/php-image-downloader
or add
"greeflas/php-image-downloader": "dev-master"
to the require section of your composer.json.
Using
Create component instance
$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
.
Then you should call method for downloading
$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.