CodeIgniter Laravel PHP Example HTML Javascript jQuery MORE Videos New

How to upload file in Laravel framework PHP

In this example we will discuss about how to upload file in Laravel framework PHP.

We use 3 file for File upload.

  1. uploadfile.php
  2. UploadFileController
  3. web.php


<!DOCTYPE html>
echo Form::open(array('url' => '/uploadfile','files'=>'true'));
echo 'Select the file to upload.';
echo Form::file('image');
echo Form::submit('Upload File');
echo Form::close();


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class UploadFileController extends Controller {
public function index(){
return view('uploadfile');
public function showUploadFile(Request $request){
$file = $request->file('image');
//Display File Name
echo 'File Name: '.$file->getClientOriginalName();
echo '
//Display File Extension
echo 'File Extension: '.$file->getClientOriginalExtension();
echo '
//Display File Real Path
echo 'File Real Path: '.$file->getRealPath();
echo '
//Display File Size
echo 'File Size: '.$file->getSize();
echo '
//Display File Mime Type
echo 'File Mime Type: '.$file->getMimeType();
//Move Uploaded File
$destinationPath = 'uploads';


/* |--------------------------------------------------------------------------
| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Warning: mysqli_connect(): (HY000/1040): Too many connections in /www/wwwroot/ on line 15
Could not Connect My Sql:Too many connections