have a problem of my excel file uploading. code is working perfectly in my localhost but not in the real server. this is my controller code:
class UploadController extends \yii\web\Controller
{
public function actionIndex()
{
$model = new UploadForm();
if (Yii::$app->request->isPost) {
$model->excelFile = UploadedFile::getInstance($model, 'excelFile');
if ($model->upload()) {
$query = Yii::$app->db->createCommand('SHOW TABLES FROM reporting')
->queryAll();
if ($query==null) {
$nodb="no";
return $this->render('index',['model' => $model,'nodb' => $nodb,]);
}else{
$this->redirect(URL_FOLDER.'backend/controllers/import.php?filename='.$model->excelFile.'&dbname='.DB_NAME);
}
}
}
return $this->render('index',['model' => $model,]);
}
}
end this is my models code:
class UploadForm extends Model
{
/**
* @var UploadedFile
*/
public $excelFile;
public function rules()
{
return [
[['excelFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'xls'],
];
}
public function upload()
{
if ($this->validate()) {
$this->excelFile->saveAs('uploads/' . $this->excelFile->baseName . '.' . $this->excelFile->extension);
return true;
} else {
return false;
}
}
}
i tried with solution in the duplicate question but it was not helpful, and can't found the php.ini in the real server