Upload file in laravel 5.4
I am uploading the file and it is showing the file also but not storing the file in folder
here is my code......Please help me
routes.php
Route::get('/view' , 'UploadsController@show');
Route::post('/upload' , 'UploadsController@upload');
upload.blade.php
@extends('blog.master')
@section('content')
{{csrf_field()}}
@endsection
uploadscontroller.php
upload.blade.php
class UploadsController extends Controller
{
public function show (){
return view ('blog.upload');
}
public function upload(){
if(Input::hasFile('file')){
echo 'Uploaded';
$file=Input::file('file');
$file->move('uploads' , $file->getClientOriginalName());
echo '<img src="uploads/' . $file->getClientOriginalName().'"/>';
}
else {
echo 'Not Uploaded';
}
}
}
Make sure you have a folder named uploads in your project root directory.
e.g MyLaravelProject\uploads
also you have to have a permission to write in the said directory.
@silverxjohn I have the folder but still no response.........what type of permission ??
here u should give full path
"public_path('/uploade) or storage_path('upload)"
@asadbinamer permission to read and write in the directory.
sudo chmod 660 upload should do the trick
Please or to participate in this conversation.