I am new to yii. I have requirement to upload a file to database & then download it from database. I’m using CUploadedFile for uploading file to server.
i have NaskahController for upload:
public function actionCreate()
{
$model=new Naskah;
if(isset($_POST['Naskah']))
{
$model->attributes=$_POST['Naskah'];
$model->lampiran=CUploadedFile::getInstance($model,'lampiran');
if($model->save())
$this->redirect(array('sent','id'=>$model->id_naskah));
}
$this->render('create',array(
'model'=>$model,
));
}
Can anyone please let me know how to add a button for DOWNLOAD that file and then this action can be appear (like image).Any help would be greatly appreciated.
then in your echo, you put your file. For example, my file is in database so I give the model field which contains the binary file. If the file is in on server you can use php simply function to print it.
In parameter I have id, file_field, and file_name, you can adapte it depending on what you want to do exactly.