laravel 5 Tutorial : Laravel 5.3 Multiple File Upload & Save Into Database

Laravel 5.3 Tutorial for beginners : How to create simple Laravel 5.3 Multiple File Upload & Save Into Database, this lessons will show you how to create Upload Form in Laravel 5.3 with multiple file upload and will save into database.

at the previews lessons we have create simple upload images in laravel 5.3 using Ajax, so please read :

Upload Images in Laravel 5.3

Video Tutorial Laravel 5.3 Multiple File Upload

Full Source Code


    public function up() {
        // create upload table
        Schema::create('upload', function(Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down() {
        // drop upload table

Model (Uploads.php)

namespace App;
use Illuminate\Database\Eloquent\Model;

class Uploads extends Model {
    // upload model
    protected $table = 'upload';

Controller (UploadsController.php)


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Validator;
use Response;
use Redirect;
use Session;
use App\Uploads;

class UploadsController extends Controller {
    public function index() {
      return view('upload.index');
    public function multiple_upload() {
      // getting all of the post data
      $files = Input::file('images');
      // Making counting of uploaded images
      $file_count = count($files);
      // start count how many uploaded
      $uploadcount = 0;

      foreach ($files as $file) {
        $rules = array('file' => 'required'); //'required|mimes:png,gif,jpeg,txt,pdf,doc'
        $validator = Validator::make(array('file'=> $file), $rules);
          $destinationPath = 'uploads'; // upload folder in public directory
          $filename = $file->getClientOriginalName();
          $upload_success = $file->move($destinationPath, $filename);
          $uploadcount ++;

          // save into database
          $extension = $file->getClientOriginalExtension();
          $entry = new Uploads();
          $entry->mime = $file->getClientMimeType();
          $entry->original_filename = $filename;
          $entry->filename = $file->getFilename().'.'.$extension;
      if($uploadcount == $file_count){
        Session::flash('success', 'Upload successfully');
        return Redirect::to('upload');
      } else {
        return Redirect::to('upload')->withInput()->withErrors($validator);

Routes (Web.php)

Route::get('upload', 'UploadsController@index');
Route::post('upload/uploadFiles', 'UploadsController@multiple_upload');

View (upload\index.blade.php)

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Multiple Upload</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src=""></script>
      <script src=""></script>

    <div class="container">
        <div class="alert-box success">
          <h2>{!! Session::get('success') !!}</h2>
      <div class="form-group">
        <h2>Simple Multiple Upload</h2>
        {!! Form::open(array('url'=>'upload/uploadFiles','method'=>'POST', 'files'=>true)) !!}
        {!! Form::file('images[]', array('multiple'=>true)) !!}
            <p>{!! Session::get('error') !!}</p>
        {!! Form::submit('Submit', array('class'=>'btn btn-lg btn-primary col-md-4')) !!}
        {!! Form::close() !!}
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src=""></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src=""></script>

Download Full source code here
see you next lessons ...

Get Latest Source Code For FREE!

Hi guys, let me introduce myself. My name is Harison, I work at an Private Company in Indonesia 'CV.Delta Microtech' as a .Net Programmer since 2010.
Please Subscribe and Follow Our Social Medias 'Sector Code' to get Latest tutorials and will be send to your email everyday for free!, Nice to meet you and Happy coding :) all ^^

Buy me a Bear, you can send me your donations to my Wallet address on below :