Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param $directory
- * @param $manufacturerId
- * @param $productId
- *
- * @return string
- */
- public function download($directory, $manufacturerId, $productId)
- {
- $extension = pathinfo($this->source, PATHINFO_EXTENSION);
- $title = Nette\Utils\Strings::webalize($this->title);
- $imageName = 'feed_' . $manufacturerId . '.' . $productId . '.' . $title . '.' . $extension;
- $try = 3;
- do {
- $targetPath = $directory . '/' . $imageName;
- if (!file_exists($targetPath) && ($imageRaw = @file_get_contents($this->source))) {
- @file_put_contents($targetPath, $imageRaw);
- @chmod($targetPath, 0777);
- }
- if (FALSE === getimagesize($targetPath)) {
- unlink($targetPath);
- } else {
- break;
- }
- } while($try--);
- return $imageName;
- }
Advertisement
Add Comment
Please, Sign In to add comment