To Upload a file on server, there is necessary Your form must be a enctype="multipart/form-data"
<html>
<body>
<?php
echo Form::open(array('url' => 'upload_file','files'=>'true'));
echo 'Select the file to upload.';
echo Form::file('image');
echo Form::submit('Upload File');
echo Form::close();
?>
</body>
</html>
In the above code this create a form tag include enctype="multipart/form-data" with file upload button
Route::get('/show_page', 'HomeController@show_page');
Route::post('/upload_file', 'HomeController@upload_file');
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use AppHttpControllersController;
class HomeController extends Controller
{
public function show_page(){
return view('fileupload');
}
public function upload_file(Request $request){
$file = $request->file('image');
echo 'File Name: '.$file->getClientOriginalName();
echo '<br>';
echo 'File Extension: '.$file->getClientOriginalExtension();
echo '<br>';
echo 'File Path: '.$file->getRealPath();
echo '<br>';
echo 'File Size: '.$file->getSize();
echo '<br>';
echo 'File Type: '.$file->getMimeType();
$destinationPath = '../upload';
$file->move($destinationPath,$file->getClientOriginalName());
}
}