Skip to content

didvc/go-filemanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Go Web File Manager

A simple, web-based file manager application built with Go that allows you to manage files and folders through a web interface.

Features

  • πŸ“ Browse directories - Navigate through folders with breadcrumb navigation
  • πŸ“€ Upload files - Upload files to any directory
  • πŸ“₯ Download files - Download files directly from the web interface
  • πŸ“ Create folders - Create new directories
  • πŸ—‘οΈ Delete files/folders - Remove files and directories
  • πŸ”’ Security - Path traversal protection to keep files within the designated directory
  • πŸ“± Responsive design - Works on desktop and mobile devices

Installation & Usage

  1. Prerequisites: Make sure you have Go installed (Go 1.21 or later)

  2. Clone or download the project files

  3. Run the application:

    go run main.go
  4. Access the file manager: Open your web browser and go to http://localhost:8080

File Structure

filemanager/
β”œβ”€β”€ main.go          # Main application file
β”œβ”€β”€ go.mod           # Go module file
β”œβ”€β”€ README.md        # This file
└── files/           # Root directory for file management (created automatically)

How to Use

Navigation

  • Click on folder names to enter directories
  • Use the "⬆️ Up" button to go to the parent directory
  • Use breadcrumb navigation to jump to any parent directory

File Operations

  • Upload File: Click "πŸ“€ Upload File" button, select a file, and click "Upload"
  • Download File: Click the "πŸ“₯ Download" button next to any file
  • Delete: Click the "πŸ—‘οΈ Delete" button next to any file or folder (confirmation required)

Folder Operations

  • Create Folder: Click "πŸ“ New Folder" button, enter a name, and click "Create"
  • Navigate: Click on any folder name to enter it

Configuration

Change Root Directory

By default, files are managed in the ./files directory. To change this, modify the rootDir variable in main.go:

rootDir = "/path/to/your/directory"

Change Port

To run on a different port, modify the port in the ListenAndServe call:

log.Fatal(http.ListenAndServe(":3000", nil))  // Changes port to 3000

Security Features

  • Path Traversal Protection: Prevents access to files outside the designated root directory
  • Safe File Operations: All file operations are validated to ensure they stay within bounds
  • Input Validation: Form inputs are validated before processing

API Endpoints

  • GET / - Main file browser interface
  • POST /upload - Upload files
  • GET /download - Download files
  • POST /mkdir - Create directories
  • POST /delete - Delete files/directories

Browser Compatibility

This application works with all modern web browsers including:

  • Chrome/Chromium
  • Firefox
  • Safari
  • Edge

Development

The application is built with:

  • Backend: Go (standard library only)
  • Frontend: HTML5, CSS3, JavaScript (vanilla)
  • Styling: Custom CSS with responsive design

Troubleshooting

Common Issues

  1. Permission Denied: Make sure the application has read/write permissions to the files directory
  2. Port Already in Use: Change the port number in main.go if port 8080 is already occupied
  3. File Upload Issues: Check that the files directory exists and is writable

Error Messages

  • "Access denied" - Attempting to access files outside the root directory
  • "Failed to read directory" - Directory doesn't exist or no read permissions
  • "Failed to create file" - No write permissions or disk space issues

License

This project is open source and available under the MIT License.


Related projects

  • astro-html-editor β€” Self-hosted HTML editor with live preview. Astro SSR + plain JavaScript, server-side file persistence.
  • html-bio-generator β€” A modern, intuitive tool for creating beautiful HTML bio pages with ease. Built with Next.js, TypeScript, and Tailwind CSS. Perfect for developers, freelancers, and content creators.
  • image-gallery-app β€” πŸ–ΌοΈ Modern minimalist image gallery built with Express.js and Vue.js - featuring drag & drop upload, responsive design, and clean aesthetics

About

πŸ—‚οΈ Modern web-based file manager built with Go. Features file preview, UTF-8 support, responsive design, and secure file operations.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors