Hello, i have some problem. I need download my (uploaded file when i create new TASK ) :
My Task Controller :
This function create new task and upload file to : basePath/upload/project_id/task_id/file.png
How i can render this file.png? and how i can download it?
Path "basePath/upload/project_id/task_id/file.png" has saved in "files" table .
My Task Controller :
public function actionCreate() { $model = new Task; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Task'])) { $model->attributes = $_POST['Task']; $uploadedFile = CUploadedFile::getInstance($model, 'image'); $fileName = time() . '_' . $uploadedFile->name; // $timestamp + file name if (!is_dir(Yii::app()->basePath . '/upload/' . $model->project->id . '/' . $model->id)) { mkdir(Yii::app()->basePath . '/upload/' . $model->project->id); } if ($model->save()) { mkdir(Yii::app()->basePath . '/upload/' . $model->project->id . '/' . $model->id); $path = Yii::app()->basePath . '/upload/' . $model->project->id . '/' . $model->id .'/'. $fileName; if ($uploadedFile->saveAs($path)) { $modelFile = new Files; $modelFile->task_id = $model->id; $modelFile->path = $path; $modelFile->save(); } }
This function create new task and upload file to : basePath/upload/project_id/task_id/file.png
How i can render this file.png? and how i can download it?
Path "basePath/upload/project_id/task_id/file.png" has saved in "files" table .