Skip to content

Instantly share code, notes, and snippets.

@Ojvar
Created February 3, 2018 20:41
Show Gist options
  • Save Ojvar/2368ed055277052b0fbea47c3092f0d4 to your computer and use it in GitHub Desktop.
Save Ojvar/2368ed055277052b0fbea47c3092f0d4 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
// $this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('home');
}
/**
* Store
*/
public function upload(Request $request)
{
$file = $request->file('image');
$name = \Storage::putFile('files', $file);
return basename($name) . ' / ' . $file->getClientOriginalName();
}
}
/////////////////// Blade file
<form action="{{ url('/upload') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="file" name="image" />
<input type="submit" value="submit" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment