MindWareZoneUploading large files can be problematic, especially when users have unstable internet connections. A...
Uploading large files can be problematic, especially when users have unstable internet connections. A failed upload often means starting over from scratch.
Fortunately, FilePond supports chunked uploads, allowing files to be split into smaller pieces and uploaded sequentially. Combined with Laravel, this provides a reliable way to handle large file uploads while supporting progress tracking and resumable uploads.
In this tutorial, we'll build a chunked file upload system using FilePond and Laravel.
<link href="https://unpkg.com/filepond/dist/filepond.min.css" rel="stylesheet" />
<script src="https://unpkg.com/filepond/dist/filepond.min.js"></script>
Make a blade file upload.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=instrument-sans:400,500,600" rel="stylesheet" />
<!-- Styles / Scripts -->
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
@vite(['resources/css/app.css', 'resources/js/app.js'])
@endif
<link href="https://unpkg.com/filepond/dist/filepond.min.css" rel="stylesheet" />
<script src="https://unpkg.com/filepond/dist/filepond.min.js"></script>
</head>
<body ">
<div>
<input type="file" class="filepond" name="file" />
</div>
<script>
const csrf = document.querySelector('meta[name="csrf-token"]').content;
FilePond.create(document.querySelector('input[type="file"]'), {
chunkUploads: true,
chunkSize: 5 * 1024 * 1024,
allowMultiple: false,
server: {
process: {
url: '/upload',
method: 'POST',
headers: {
'X-CSRF-TOKEN': csrf
}
},
patch: {
url: '/upload/',
method: 'PATCH',
headers: {
'X-CSRF-TOKEN': csrf,
'Accept': 'application/json'
}
},
revert: {
url: '/revert',
method: 'DELETE',
headers: {
'X-CSRF-TOKEN': csrf
}
}
}
});
</script>
</body>
</html>
Read The Full Tutorial: