Tarikul Islam Logo

TARIKUL

HomeAboutSkillsServicesExperiencePortfolioBlogContact
TARIKUL.DEV

© 2021 - 2026 TARIKUL ISLAM. All rights reserved.

  1. Home
  2. Blog
  3. A Complete Guide to Uploading & Syncing Your Project Files via FTP
Back to Blog
Tech

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

TARIKUL ISLAM

TARIKUL ISLAM

December 6, 20252 min read90 views
A Complete Guide to Uploading & Syncing Your Project Files via FTP

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:

  1. HTML templates
  2. Static websites (Vite, Next.js static export, Astro, Nuxt static, etc.)
  3. WordPress theme files
  4. 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:

project-root/
│
├── ftp_config.json
├── upload.js
└── README.md

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:

{
"ftp": {
"host": "ftp.yourdomain.com",
"user": "yourusername",
"password": "yourpassword",
"secure": false,
"remoteDir": "/",
"localDir": "dist"
}
}

You only need to customize it once for your project.

📦 The Upload Script

Below is the complete upload.js script that handles everything:



// (Your full script here – omitted for brevity)
// I can insert it fully if you want the blog to include it too.

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:

node upload.js

The script will:

  1. Load your config
  2. Connect to the FTP server
  3. Clear the remote directory
  4. Upload your local dist folder
  5. 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.


TARIKUL ISLAM

About TARIKUL ISLAM

Programmer and Developer

#FTP#Automation
Share this article:

← Previous

MongoDB Backup & Restore Utility – A Developer-Friendly Way to Protect Your Data

Recent Posts

MongoDB Backup & Restore Utility – A Developer-Friendly Way to Protect Your Data

MongoDB Backup & Restore Utility – A Developer-Friendly Way to Protect Your Data

Dec 6

Tags

#FTP#Automation