Import Excel in Yii2
<p>I have yii2 application using advanced template and database mySql, i already make function for import an excel file to one of the table,
I made the function in a controller named student that contains CRUD of students data.this is my code</p>

<pre><code> public function actionImportExcel()
{
    $inputFile = 'uploads/siswa_file.xlsx';
    try{
        $inputFileType = \PHPExcel_IOFactory::identify($inputFile);
        $objReader = \PHPExcel_IOFactory::createReader($inputFileType);
        $objPHPExcel = $objReader-&gt;load($inputFile);
    } catch (Exception $e) {
        die('Error');
    }

    $sheet = $objPHPExcel-&gt;getSheet(0);
    $highestRow = $sheet-&gt;getHighestRow();
    $highestColumn = $sheet-&gt;getHighestColumn();

    for($row=1; $row &lt;= $highestRow; $row++)
    {
        $rowData = $sheet-&gt;rangeToArray('A'.$row.':'.$highestColumn.$row,NULL,TRUE,FALSE);

        if($row==1)
        {
            continue;
        }

        $siswa = new Siswa();
        $siswa-&gt;nis = $rowData[0][0]; 
        $siswa-&gt;nama_siswa  = $rowData[0][1]; 
        $siswa-&gt;jenis_kelamin  = $rowData[0][2]; 
        $siswa-&gt;ttl  = $rowData[0][3]; 
        $siswa-&gt;alamat  = $rowData[0][4]; 
        $siswa-&gt;telp  = $rowData[0][5]; 
        $siswa-&gt;agama  = $rowData[0][6]; 
        $siswa-&gt;nama_ortu  = $rowData[0][7]; 
        $siswa-&gt;telp_ortu  = $rowData[0][8]; 
        $siswa-&gt;pekerjaan_ortu = $rowData[0][9];
        $siswa-&gt;tahun_masuk = $rowData[0][10];
        $siswa-&gt;kelas = $rowData[0][11];
        $siswa-&gt;save();

        print_r($siswa-&gt;getErrors());
    }
    die('okay');
}
</code></pre>

<p>but i don't know how to make a button in a view to make this function work. i mean i want to make a button that when the user click the button and browse their excel file they can import that file and the data inside the excel can import to database</p>