yii-1.1.14.f0fee9.tar.gz i am new but i am not sure why i cant upload file, it shows me "no file selected message" if i put the wrong filename type it validates but with pdf nothing
this are my files:
controller:
public function actionCreate()
{
$model=new Files;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Files']))
{
$model->attributes=$_POST['Files'];
$filename = CUploadedFile::getInstance($model, 'path');
if ($filename !== null )
{
$rfname = rand(0, 9999) . $filename;
$model->path = $rfname;
}
if($model->save()) {
if ($filename !== null)
{
$path = Yii::app()->basePath . '/../pdfs/' . $rfname;
$model->path->saveAs($path);
}
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
model:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, initial_date, end_date, product_id', 'required'),
array('path', 'file',
'allowEmpty'=>true,
'types'=> 'pdf',
'maxSize' => 1024*1024* 10, // 10MB
'tooLarge' => 'File very big',
'wrongType' => 'Debe ser un archivo pdf'),
array('product_id', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>128),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, name, initial_date, end_date, product_id', 'safe', 'on'=>'search'),
);
}
and _form.php
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'files-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
'htmlOptions'=>
array( 'enctype' => 'multipart/form-data'),
)); ?>
<div class="row">
<?php echo $form->labelEx($model,'path'); ?>
<?php echo $form->fileField($model, 'path'); ?>
<?php echo $form->error($model, 'path'); ?>
</div>
what could be wrong?