| title | keywords | description | ||||
|---|---|---|---|---|---|---|
File Upload |
|
Handling file uploads in a Go application. |
This example demonstrates how to handle file uploads using Go Fiber.
This project provides a basic setup for handling file uploads in a Go Fiber application. It includes examples for uploading single and multiple files, as well as saving files to different directories.
single/main.go: Example for uploading a single file to the root directory.single_relative_path/main.go: Example for uploading a single file to a relative path.multiple/main.go: Example for uploading multiple files.go.mod: The Go module file.
-
Clone the repository:
git clone https://github.com/gofiber/recipes.git cd recipes/upload-file -
Install the dependencies:
go mod download
-
Navigate to the
singledirectory:cd single -
Run the application:
go run main.go
-
Use a tool like
curlor Postman to upload a file:curl -F "document=@/path/to/your/file" http://localhost:3000/
-
Navigate to the
single_relative_pathdirectory:cd single_relative_path -
Run the application:
go run main.go
-
Use a tool like
curlor Postman to upload a file:curl -F "document=@/path/to/your/file" http://localhost:3000/
-
Navigate to the
multipledirectory:cd multiple -
Run the application:
go run main.go
-
Use a tool like
curlor Postman to upload multiple files:curl -F "documents=@/path/to/your/file1" -F "documents=@/path/to/your/file2" http://localhost:3000/
Handles uploading a single file to the root directory.
Handles uploading a single file to a relative path.
Handles uploading multiple files.
This example provides a basic setup for handling file uploads in a Go Fiber application. It can be extended and customized further to fit the needs of more complex applications.