laravel 8 file upload code example
Example 1: laravel store file
$path = $request->file('avatar')->store(
'avatars', 'public'
);
Example 2: laravel file upload
$('form').submit(function(event) {
event.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({
url: '{{ url('/agents') }}',
type: 'POST',
data: formData,
success: function(result)
{
location.reload();
},
error: function(data)
{
console.log(data);
}
});
});