File Uploads & Downloads in JavaScript

From the Axios cheat sheet · Advanced Patterns · verified Jul 2026

File Uploads & Downloads

Handle file uploads with progress and file downloads

javascript
// File upload
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('name', 'Document');

const response = await axios.post('/api/upload', formData, {
  headers: {
    'Content-Type': 'multipart/form-data'
  },
  onUploadProgress: (progressEvent) => {
    const percent = Math.round(
      (progressEvent.loaded * 100) / progressEvent.total
    );
    console.log(\`Upload: \${percent}%\`);
  }
});
✅ Use responseType: "blob" for file downloads to handle binary
💡 onUploadProgress and onDownloadProgress track transfer progress
🔍 FormData auto-sets Content-Type with proper boundary
⚡ Implement chunked uploads for files larger than 100MB
uploaddownloadfilesformdataprogress

Continue with Axios

Save the full cheat sheet or work through every related task.

More JavaScript tasks

Back to the full Axios cheat sheet