diff --git a/_examples/file-server/file-server/main.go b/_examples/file-server/file-server/main.go index 0ce54002..3e0bdb68 100644 --- a/_examples/file-server/file-server/main.go +++ b/_examples/file-server/file-server/main.go @@ -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 } diff --git a/_examples/file-server/file-server/views/upload.html b/_examples/file-server/file-server/views/upload.html index 6954b82f..a278be2e 100644 --- a/_examples/file-server/file-server/views/upload.html +++ b/_examples/file-server/file-server/views/upload.html @@ -1,17 +1,38 @@ +