1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

Add tutorial for DropzoneJS. Stay tuned for two-parts article series on https://medium.com/@kataras and https://dev.to/@kataras

Former-commit-id: 2aac5c1f5a5b5a7039a7a5fad3312a49e9311ddd
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-10-03 05:14:53 +03:00
parent c6a3b47573
commit 000d1b000d
11 changed files with 3132 additions and 5 deletions

View File

@@ -16,16 +16,16 @@ func main() {
app.RegisterView(iris.HTML("./templates", ".html"))
// Serve the form.html to the user
// Serve the upload_form.html to the client.
app.Get("/upload", func(ctx iris.Context) {
//create a token (optionally)
// create a token (optionally).
now := time.Now().Unix()
h := md5.New()
io.WriteString(h, strconv.FormatInt(now, 10))
token := fmt.Sprintf("%x", h.Sum(nil))
// render the form with the token for any use you like
// render the form with the token for any use you'd like.
ctx.ViewData("", token)
ctx.View("upload_form.html")
})
@@ -34,7 +34,7 @@ func main() {
app.Post("/upload", iris.LimitRequestBodySize(10<<20),
func(ctx iris.Context) {
// or use ctx.SetMaxRequestBodySize(10 << 20)
//to limit the uploaded file(s) size.
// to limit the uploaded file(s) size.
// Get the file from the request
file, info, err := ctx.FormFile("uploadfile")