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’ => […]
Category Archives: Yii Files
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(); }
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){ […]
In this article, I explained about “How to handle zip files” in yii framework. I used this code to my project for handling the zip files. Here i added source code to create, Extract, Download and Delete zip files in yii framework. Create Zip Files in Yii Extract Zip Files in Yii Download Zip Files […]