-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤔 file upload #47
Labels
🤔 Question
Further information is requested
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! |
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
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))
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question description
I looked at the single file upload recipe. How do I specify a directory other than the root
Code snippet (optional)
The text was updated successfully, but these errors were encountered: