A complete file upload system that allows users to upload files and automatically send them to recipients' emails using n8n automation and Gmail.
✨ Modern Web Interface - Beautiful, responsive UI for file uploads
📤 Drag & Drop Support - Easy file upload with drag and drop
📧 Email Integration - Sends files as email attachments via Gmail
🔐 Secure - File validation and size limits (50MB max)
⚡ Fast - Built with Express.js and optimized for performance
📱 Mobile Responsive - Works great on all devices
File Upload Project/
├── server.js # Node.js/Express backend
├── package.json # Project dependencies
├── .env # Environment configuration
├── n8n-workflow.json # n8n automation workflow
├── public/
│ └── index.html # Frontend UI
└── uploads/ # Temporary file storage (auto-created)
- Node.js (v14 or higher) - Download
- n8n (v0.200+) - Installation Guide
- Gmail Account - For sending emails
cd "d:\Gitam Leaker\N8N Workflows\File Upload Project"
npm installThis installs:
express- Web server frameworkmulter- File upload handlingcors- Cross-origin supportaxios- HTTP client for n8n webhookdotenv- Environment variable management
Edit .env file with your settings:
PORT=3000
N8N_WEBHOOK_URL=http://localhost:5678/webhook/file-uploadKey Variables:
PORT- Server port (default: 3000)N8N_WEBHOOK_URL- Your n8n webhook URL
In your n8n instance:
- Create New Workflow
- Add Webhook Node (Webhook trigger)
- Set Authentication:
None - Copy the webhook URL and update
.envwith it
- In n8n, add Gmail Node to your workflow
- Click Add Gmail Credential
- Authenticate with your Gmail account:
myn8nuploade@gmail.com - Set up as shown in
n8n-workflow.json
Important: Enable "Less secure app access" or use App Password:
- Go to myaccount.google.com
- Security → App Passwords → Generate for Mail
Use the provided n8n-workflow.json:
- In n8n Dashboard, click Import
- Select the
n8n-workflow.jsonfile - Configure your Gmail credentials
- Activate the workflow
Workflow Steps:
- ✓ Webhook receives file upload request
- ✓ Email node sends file as attachment
- ✓ Success response returned
npm startOutput should show:
Server running on http://localhost:3000
n8n Webhook URL: http://localhost:5678/webhook/file-upload
- Open
http://localhost:3000in browser - Enter recipient email address
- (Optional) Enter your name
- Select or drag-drop a file
- Click Send File
- File sent successfully! ✓
User Upload → Node.js Server → File Storage → n8n Webhook
↓
Email Sent → Gmail → Recipient's Inbox (with attachment)
SendGrid Alternative:
// Replace Gmail node with SendGrid node
// Update credentials and email templateOutlook/Office365:
// Use Outlook node instead of Gmail
// Configure Microsoft credentials- Ensure n8n is running:
n8n start - Check n8n is on port 5678
- Verify Gmail credentials in n8n
- Check "Less secure app" is enabled
- Verify recipient email is correct
- Ensure
uploads/directory exists - Check file permissions on the server
- Verify file path in n8n workflow
- Current limit: 50MB
- Edit
server.jsline to increase:limits: { fileSize: 100 * 1024 * 1024 } // 100MB
Request:
{
"file": File, // File object
"recipientEmail": "email@here", // Required
"senderName": "John Doe" // Optional
}Response:
{
"success": true,
"message": "File uploaded and sent successfully",
"file": "filename.pdf",
"recipientEmail": "user@example.com"
}- Use environment variables for sensitive data
- Implement authentication for upload endpoint
- Use HTTPS/SSL certificates
- Set up rate limiting
- Validate file types on server
- Clean up old temp files regularly
- Use secure file storage (S3, Google Drive, etc.)
- Max Size: 50MB (configurable)
- Allowed Types: All (configure in multer fileFilter)
- Storage: Local
uploads/directory (temp)
Edit the htmlText in n8n Gmail node:
<h2>Custom Header</h2>
<p>Your custom message here</p>
<p>File: {{ $node.Webhook.json.file.filename }}</p>In server.js:
fileFilter: (req, file, cb) => {
const allowedMimes = ['application/pdf', 'application/msword'];
if (allowedMimes.includes(file.mimetype)) {
cb(null, true);
} else {
cb(new Error('Invalid file type'));
}
}Modify CSS in public/index.html inside <style> tag
| Variable | Default | Description |
|---|---|---|
PORT |
3000 | Server port |
N8N_WEBHOOK_URL |
http://localhost:5678/webhook/file-upload | n8n webhook URL |
On Network:
# Server listens on all interfaces
# Access from: http://YOUR_IP:3000Docker Support (Optional):
FROM node:16
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]- Check server logs:
npm startoutput - Verify file permissions
- Check n8n webhook is active
- Validate email credentials
- Test with sample file first
MIT - Free to use and modify
Ready to use! 🚀 Start with npm start and open http://localhost:3000