mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
file-server example: add upload using javascript button
Former-commit-id: caaec95388e691c2db27a55e649c758f93ab537c
This commit is contained in:
@@ -20,6 +20,8 @@ func init() {
|
||||
func main() {
|
||||
app := iris.New()
|
||||
app.RegisterView(iris.HTML("./views", ".html"))
|
||||
// Serve assets (e.g. javascript, css).
|
||||
// app.HandleDir("/public", "./public")
|
||||
|
||||
app.Get("/", index)
|
||||
|
||||
@@ -47,10 +49,14 @@ func uploadView(ctx iris.Context) {
|
||||
ctx.View("upload.html", token)
|
||||
}
|
||||
|
||||
const maxSize = 10 * iris.MB
|
||||
|
||||
func upload(ctx iris.Context) {
|
||||
ctx.SetMaxRequestBodySize(maxSize)
|
||||
|
||||
_, err := ctx.UploadFormFiles("./uploads", beforeSave)
|
||||
if err != nil {
|
||||
ctx.StopWithError(iris.StatusInternalServerError, err)
|
||||
ctx.StopWithError(iris.StatusPayloadTooRage, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user