Yii Hint For Files Handling

This post will help you to learn “how to delete files in yii framework”. I deleted singele file and all files from directory.

Delete All Files Inside Directory

php glob() method used to read all files from directory of yii application and unlink() method used to delete the files.

   //your directory                                
   foreach(glob($dir.'*.*') as $files){

When we use above method , All files will be deleted inside directory

Delete Single File

Get the base directory of yii application using Yii::app()->basePath and assign the folder path, file path to delete the file. apply unlink() to delete the file.

   //your file path

Leave a Reply

Your email address will not be published. Required fields are marked *