Frontend Development 2 min read

Implement Drag‑and‑Drop File and Directory Upload with trzsz in the Browser

This guide explains how to enable Windows cmd/PowerShell support, directory upload/download commands, and drag‑and‑drop file or folder uploading in a web page using trzsz/trzsz‑go, including the required server setup and a JavaScript code example.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Implement Drag‑and‑Drop File and Directory Upload with trzsz in the Browser

The article introduces trzsz (or trzsz‑go) as a tool that supports Windows local terminals such as cmd and PowerShell, and provides commands for uploading directories ( trz -d ) and downloading files ( tsz -d xxx ).

It demonstrates that files and entire directories can be dragged directly onto a web page and uploaded to the server. By adding a small JavaScript snippet to the page, the drag‑over and drop events are handled, the default browser behavior is prevented, and the selected items are passed to trzszFilter.uploadFiles for transfer.

terminalHtmlElement.addEventListener("dragover", (event) => event.preventDefault());
terminalHtmlElement.addEventListener("drop", (event) => {
  event.preventDefault();
  trzszFilter
    .uploadFiles(event.dataTransfer.items)
    .then(() => console.log("upload success"))
    .catch((err) => console.log(err));
});

To make the upload work, the server must have trz or trzsz-go installed and the executable placed in a directory listed in the system PATH .

After following these steps, users can conveniently transfer files and folders from their browsers to the server with a simple drag‑and‑drop interface.

frontendJavaScriptFile Uploaddrag-and-droptrzsz
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.