public function get() { if (!($dataImage = $this->captcha->get())) { return '#'; } if ($dataImage['mime_type'] === 'image/x-png') { $ext = '.png'; } elseif ($dataImage['mime_type'] === 'image/jpeg') { $ext = '.jpg'; } else { $ext = '.gif'; } $uniq = uniqid(); $path = Alias::getAlias('@assets') . DS . 'cache' . DS . 'captcha' . DS . $uniq . $ext; if (FileHelper::create($path, $dataImage['image'])) { return Alias::getAlias('@web') . '/cache/captcha/' . $uniq . $ext; } return '#'; }
/** * Create file * * @param string $path * @param string $value * @return bool */ protected function createFile($path, $value) { return FileHelper::create($path, "<?php\n" . $value, LOCK_EX); }