I have uploaded files using CUploadedFile and then applied cThumb to create the thumb, But now what if i want to delete the uploaded file using the CRUD action?
Thanks in advance
I have uploaded files using CUploadedFile and then applied cThumb to create the thumb, But now what if i want to delete the uploaded file using the CRUD action?
Thanks in advance
Use unlink function.
The following is an example.
public function actionDelete($id)
{
$model = ModelName::model()->findByPk($id);
$model->delete();
$imagePath = Yii::getPathOfAlias('webroot.images').DIRECTORY_SEPARATOR;
$thumbPath = $imagePath.'thumb'.DIRECTORY_SEPARATOR;
$image = $imagePath.$model->image;
$thumb = $thumbPath.$model->image;
if (file_exists($image) && !is_dir($image))
unlink($image);
if (file_exists($thumb) && !is_dir($thumb))
unlink($image);
$this->redirect(array('somewhere'));
}