Laravel makes it very easy to store uploaded files using the store method on an uploaded file instance. Laravel call the store method with the path at which you wish to store the uploaded file.

Create Routes

routes/web.php : In next step, we will add new two routes in web.php file.

Route::get('/', function () {
    return view('fileuploading');

Creating The FileUploadController

Create a controller file UserController.php and save it in the following path app/Http/Controllers/UserController.php.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class UserController extends Controller {
   public function fileuploading(Request $request) {
        $fileName = time().$request->file->getClientOriginalName();  
        $request->file->move(public_path('uploads'), $fileName);
        return back()
            ->with('success','successfully upload file.');

Creating The View

Create a view file fileuploading.blade.php and save the below code it in resources/views/fileuploading.blade.php.

<!DOCTYPE html>
        <title>Login form</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <script src=""></script>
        <script src=""></script>
        <div class="container" style="margin-top: 50px">
            <div class="row">
                <form action="fileuploading" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-6">
                            @if ($message = Session::get('success'))
                            <div class="alert alert-success alert-block">
                                <button type="button" class="close" data-dismiss="alert">×</button>
                                    <strong>{{ $message }}</strong>
                            <input type="file" name="file" class="form-control">
                            <br />
                            <button type="submit" class="btn btn-primary">Upload</button>


Let us execute this example by the following URL in the browser. This URL may be different based on your website.