Comments (2)
You can specify either to save files in a local folder under the current working directory or you can provide a relative path to specify where you wish to save the uploads.
Pleaseπ note that you must first create the uploads folder with appropriate read and write permissions before hand π.
Linux / Unix folder creation sample
mkdir /tmp/uploads_relative && chmod 0760 /tmp/uploads_relative/
mkdir uploads && chmod 0760 uploads
Code snippet
// β‘οΈ Fiber is an Express inspired web framework written in Go with βοΈ
// π€ Github Repository: https://github.com/gofiber/fiber
// π API Documentation: https://docs.gofiber.io
package main
import (
"fmt"
"log"
"github.com/gofiber/fiber"
)
func main() {
// Fiber instance
app := fiber.New()
// Routes
app.Post("/", func(c *fiber.Ctx) {
// Get first file from form field "document":
file, err := c.FormFile("document")
// Check for errors:
if err == nil {
// π· Save file to root directory:
c.SaveFile(file, fmt.Sprintf("./%s", file.Filename))
// π· Save file inside uploads folder under current working directory:
c.SaveFile(file, fmt.Sprintf("./uploads/%s", file.Filename))
// π· Save file using a relative path:
c.SaveFile(file, fmt.Sprintf("/tmp/uploads_relative/%s", file.Filename))
}
})
// Start server
log.Fatal(app.Listen(3000))
}
from recipes.
Thanks for opening your first issue here! π Be sure to follow the issue template!
from recipes.
Related Issues (20)
- fiber seems not support cancelContext like net/http π€ HOT 2
- How to modify response body through fiber.Static.ModifyResponse? π€ HOT 2
- π Bug on the auth-jwt recipe, log in with email doesn't work HOT 2
- π SvelteKit Recipe needs an update HOT 8
- π€SSE example: how can I add an endpoint to fire en event HOT 2
- π€ User Login System and Admin Area HOT 5
- π₯ any pwa example? HOT 4
- π€ websocket-chat: send websocket messages in parallel HOT 6
- π€ Close Database connection HOT 1
- I want the JWT data in my route, how to Get that? HOT 2
- π₯ Any fiber Client recipes?? HOT 8
- π auth-jwt project panics in UpdateUser handler HOT 4
- Dependency Dashboard HOT 1
- π BodyParser always returning nil HOT 3
- Bug in Login flow of auth-jwt section of the gofiber/recipesπ HOT 9
- π₯ I have a nice feature for gorm-mysql listed below: HOT 1
- π€ Issue with interface assignment in recipe "auth-jwt"? panic: interface conversion: interface {} is *jwt.Token, not *jwt.Token (types from different packages) HOT 3
- Is there any advantaje using ctx.UserContext() and pass it into GORM dbInstance.withContext() method? π€ HOT 3
- π₯ fiber-bootstrap should have clear setup instructions HOT 2
- Deprecated Recipe from gRPC Side HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recipes.