Upload files in laravel 5
Upload files or images in laravel 5
It’s easy to working with files or images in laravel 5. we can easily validate and upload files in laravel 5. laravel 5 have it’s own functions to make files upload easy and fast. i am sharing some code to upload image in laravel 5 or any of files type. it’s also easy to validate file types.
1. create a form with attribute ‘files’=>true or try below code (in my case i have resources/views/pages/upload.blade.php) :
<div class="about-section">
<div class="text-content">
<div class="span7 offset1">
@if(Session::has('success'))
<div class="alert-box success">
<h2>{!! Session::get('success') !!}</h2>
</div>
@endif
<div class="secure">Upload form</div>
{!! Form::open(array('url'=>'apply/upload','method'=>'POST', 'files'=>true)) !!}
<div class="control-group">
<div class="controls">
{!! Form::file('image') !!}
<p class="errors">{!!$errors->first('image')!!}</p>
@if(Session::has('error'))
<p class="errors">{!! Session::get('error') !!}</p>
@endif
</div>
</div>
<div id="success"> </div>
{!! Form::submit('Submit', array('class'=>'send-btn')) !!}
{!! Form::close() !!}
</div>
</div>
</div>
2. create a controller and add below function (in my case i have ApplyController):
<?php namespace App\Http\Controllers;
use Input;
use
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5 Laravel 5.1