A Complete Guide to Uploading & Syncing Your Project Files via FTP
TARIKUL ISLAM

A Complete Guide to Uploading & Syncing Your Project Files via FTP
Keeping your server updated manually through FTP can be slow, repetitive, and error-prone—especially when you’re deploying front-end projects, static sites, or build folders like dist.
Wouldn’t it be easier if deployment were just one command?
In this guide, I’ll show you how to automate FTP uploads using a clean and efficient Node.js script. This script connects to your FTP server, clears the destination folder, and uploads your latest build automatically. Perfect for developers, freelancers, and anyone maintaining static websites.
🎯 Why Automate FTP Uploads?
Most shared hosting providers still rely on FTP for deployment. If you work with:
- HTML templates
- Static websites (Vite, Next.js static export, Astro, Nuxt static, etc.)
- WordPress theme files
- Client projects on shared hosting
…then FTP uploads are unavoidable.
But instead of dragging folders into FileZilla every time, you can run:
And your entire site updates instantly. ✔️
⚙️ What This Script Does
This Node.js script:
Source Code:
=> https://github.com/faketi101/simple-ftp-upload-script
✅ Connects to your FTP server
Credentials are stored safely in a ftp_config.json file.
✅ Completely clears the remote directory
No outdated files. No conflicts. No manual cleanup.
✅ Uploads your entire local directory recursively
Perfect for build folders like dist.
✅ Keeps configuration simple and reusable
Just set it once, and reuse for any project.
🧩 Project Structure
Your setup looks like this:
The ftp_config.json file contains your server credentials and both local & remote directory paths.
🛠️ Example FTP Config
Here’s a sample ftp_config.json:
You only need to customize it once for your project.
📦 The Upload Script
Below is the complete upload.js script that handles everything:
This script uses the basic-ftp package to handle directory traversal, recursive deletion, and uploads.
🚀 How to Use the Script
Once you’ve set up ftp_config.json and upload.js, run:
The script will:
- Load your config
- Connect to the FTP server
- Clear the remote directory
- Upload your local dist folder
- Log every step so you know exactly what’s happening
Deployment completed—with zero manual FTP work.
🛡️ Security Tip
Never commit your ftp_config.json file to GitHub or any public repository.
Always add it to your .gitignore.


