#view
#disable CSRF token @Kernel.php
#route
use Illuminate\Support\Facades\Input;
or
aliases array as below config\app.php
‘Input’ => Illuminate\Support\Facades\Input::class,
and
Route::post(‘upload’, function(){
$avarta = Input::file(‘fileToUpload’);
if(strpos($avarta->getClientMimeType(),’image’) !== FALSE){
$upload_folder = ‘/assets/uploads/’;
$file_name = str_random(). ‘.’ . $avarta->getClientOriginalExtension();
$avarta->move(public_path() . $upload_folder, $file_name);
echo URL::asset($upload_folder . $file_name); // get upload file url
return Response::make(‘Success’, 200);
}else{
return Response::make(‘Avatar must be image’, 400); // bad request
}});