Category Archives: Yii Files

CSV File To DB In Yii

CSV File Upload Read CSV In Controller CSV File Upload Using the below code i created the form “importcsvform.php”. importcsvform <div class=”form”> <?php $form=$this->beginWidget(‘CActiveForm’, array( ‘id’=>’csv-form’, ‘enableAjaxValidation’=>false, ‘htmlOptions’=>array(‘enctype’ => ‘multipart/form-data’), )); ?> <?php //echo $form->errorSummary($model); ?> <div class=”row”> <?php echo $form->labelEx($model,’csvfile’); ?> <?php $this->widget(‘CMultiFileUpload’, array( ‘model’=>$model, ‘name’ => ‘csvfile’, ‘max’=>1, ‘accept’ => ‘csv’, ‘duplicate’ => […]

Update Zip files in yii

Update Zip Files Using PHP I added the source code to add new file into existing zip files. SourceCode: public function actionUpdatezip($zipfilename,$filelist){ $destination=Yii::app()->basePath.’/files/’.$zipfilename.”.zip”; $zip=new ZipArchive(); if(!$zip->open($destination)) { return false; } if($filelist) { foreach($filelist as $thefile) { $filemodel=new Filesmodle; $randno=rand(11111,99999); $filename=$randno.$thefile->name; // yii magic method $zip->addFile($thefile->tempname,$filename); //$fileext=$thefile->extensionName; //$filemodel->Size=$thefile->size; } } $zip->close(); }

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 $dir=Yii::app()->basePath.’/files/foldername/’; foreach(glob($dir.’*.*’) as $files){ […]