/** * @return string */ public function run() { $this->registerClientScript(); $attributeValue = $this->model->{$this->attribute}; $file = File::findOne(['fid' => $attributeValue]); return $this->renderFile(dirname(__FILE__) . '/views/widget.php', ['id' => $this->options['id'], 'name' => Html::getInputName($this->model, $this->attribute), 'fileInputId' => $this->id, 'fileInputName' => "_fileinput_" . $this->id, 'fid' => $attributeValue, 'url' => isset($file) ? $file->url : null, 'uploadUrl' => $this->uploadUrl, 'deleteUrl' => $this->deleteUrl]); }
/** * @return string * @throws HttpException */ public function run() { $file = File::findOne(['fid' => $this->fileParam]); if (file_exists($file->path)) { unlink($file->path); } if ($file->delete() === FALSE) { throw new HttpException(400); } return Json::encode($this->fileParam); }