file upload in laravel code example
Example 1: laravel link storage to public
php artisan storage:link
Example 2: autoload file in laravel
Inside composer.json file
"autoload": {
"files": [
"app/Helpers/helpers.php"
]
}
Example 3: laravel store file
$path = $request->file('avatar')->store(
'avatars', 'public'
);
Example 4: 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);
}
});
});