Laravel : How to Import Excel file to Database
<p>I want to import some data through Excel file to Database. But while uploading Noting get uploaded in Database.</p>

<p>I'm not sure what's the wrong here, if anyone found out, hope help me to find it.</p>

<p>Here is my controller:</p>

<pre><code> public function importExcel()
    {
        if(Input::hasFile('import_file')){
            $path = Input::file('import_file')-&gt;getRealPath();

            $data = Excel::load($path, function($reader){})-&gt;get()-&gt;toArray();
            if(!empty($data) &amp;&amp; $data-&gt;count()){
                foreach ($data as $key =&gt; $value) {
                    $insert[] = ['title' =&gt; $value-&gt;title, 'description' =&gt; $value-&gt;description];
                }
                if(!empty($insert)){
                    DB::table('items')-&gt;insert($insert);
                //  dd('Insert Record successfully.');
                }
            }
        }
        return back();

        }
</code></pre>

<p>And here is the blade view:</p>

<pre><code>&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;title&gt;Import - Export Laravel 5&lt;/title&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" &gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;nav class="navbar navbar-default"&gt;
        &lt;div class="container-fluid"&gt;
            &lt;div class="navbar-header"&gt;
                &lt;a class="navbar-brand" href="#"&gt;Import - Export in Excel and CSV Laravel 5&lt;/a&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/nav&gt;
    &lt;div class="container"&gt;
        &lt;a href="{{ URL::to('downloadExcel/xls') }}"&gt;&lt;button class="btn btn-success"&gt;Download Excel xls&lt;/button&gt;&lt;/a&gt;
        &lt;a href="{{ URL::to('downloadExcel/xlsx') }}"&gt;&lt;button class="btn btn-success"&gt;Download Excel xlsx&lt;/button&gt;&lt;/a&gt;
        &lt;a href="{{ URL::to('downloadExcel/csv') }}"&gt;&lt;button class="btn btn-success"&gt;Download CSV&lt;/button&gt;&lt;/a&gt;
        &lt;form style="border: 4px solid #a1a1a1;margin-top: 15px;padding: 10px;" action="{{ URL::to('importExcel') }}" class="form-horizontal" method="post" &gt;
            &lt;input type="file" name="import_file" /&gt;
              {!! Form::token(); !!}
            {!!   csrf_field() ; !!} 
            &lt;button class="btn btn-primary"&gt;Import File&lt;/button&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>And I wanted to upload a file like below Image :
<a href="https://i.stack.imgur.com/aHdvT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aHdvT.png" alt="enter image description here"></a></p>