Created
February 3, 2018 20:41
-
-
Save Ojvar/2368ed055277052b0fbea47c3092f0d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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