Issue
I need help to get file and type of the file which i upload.
My controller is next:
public function actionUpload()
{
$model=new Entryfile;
$exstansion = Extansion::model()->findAll();
$some = array();
foreach ($exstansion as $key=>$value)
$some[$value->idExt]=$value->ExtansionName;
if(isset($_POST['Entryfile'])) {
$model->attributes=$_POST['Entryfile'];
//$model->uUserID = $_POST['User']['uUserID'];
//Yii::import('ext.helpers.EDownloadHelper');
//EDownloadHelper::download(Yii::getPathOfAlias('dms.upload').DIRECTORY_SEPARATOR.'name');
$model->eeFileName=CUploadedFile::getInstance($model,'eeFileName');
if($model->save()) {
$model->eeFileName->saveAs('upload/'.$model->eeFileName->name);
$this->redirect(array('view','id'=>$model->eeEntryFileID));
}
}
$this->render('upload',array('model'=>$model, 'exstansion'=>$some));
}
I need solution for file size and file type. I want to save file and size in database table. But I need step by step instruction, in code if it is possible.
Solution
You can get the file size by getSize()
method:
$size=$model->eeFileName->getSize();
and you can get file type by using getType()
:
$type=$model->eeFileName->getType();
For more information check the CUploadedFile
Documents.
Answered By - Ali MasudianPour
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.