func Hash(s *nstuff.Host) { s.Print(`<!doctype html> <html lang="vn"> <head> <meta charset="utf-8"> <title>Image Index Uploader</title> <script> function submit() { document.getElementById("form").submit(); } `) file, header, err := s.File("file") if err == nil { if err == nil { filetype := header.Header.Get("Content-Type") if filetype == "image/jpeg" || filetype == "image/png" || filetype == "image/gif" { m, _, err := tipimage.Decode(file) if err == nil { h := md5.New() io.Copy(h, file) checksum := base64.URLEncoding.EncodeToString(h.Sum(nil)) phash, p := PHash(m) FindImage(s, checksum, phash, p) } else { s.Print("error=invalid_image&err_detail=", err.Error()) } } } else { s.Print("error=invalid_input") } } s.Print(` </script> </head> <body> <form id="form" method="post" enctype="multipart/form-data" action="hash"> <input id="uploader" type="file" name="file" onchange="submit();" /> </form> </body> </html> `) }