I am trying to take a file that is uploaded by the user and move it to a folder named "Images" inside of my Laravel Public file, I have managed to get it to execute successfully with no errors, my only issue is that the uploaded file wont show inside of the /Images folder.
My function is as follows:
public function contactPost(Request $request)
{
if($request->hasFile('attachment'))
{
$file = $request->file('attachment');
$file->move('Users/jvb/laravel/public/Images', $file->getClientOriginalName());
echo 'File name '.$file->getClientOriginalName();
echo "<br>";
} else {
return "No";
}
}
The blade.php file is as follows:
@extends('layouts.master')
@section('content')
<form method="POST" enctype="multipart/form-data" action="{{ route('contactPost') }}">
@csrf
<div class="form-group">
<input class="form-control" name='name' type="text" placeholder="Name">
</div>
<div class="form-group">
<input class="form-control" name='email' type="email" placeholder="Email">
</div>
<div class="form-group">
<textarea class="form-control" name="message" id="" cols="30" rows="10" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input class="form-control" name="attachment" type="file">
</div>
<div class="form-group">
<button type="submit" class="form-control">Send Message</button>
</div>
</form>
@endsection
Location of image folder within my laravel project is:
What am I doing wrong and how fix this?