nothing working yet but making small progress

This commit is contained in:
Expand-sys 2022-08-17 22:01:22 +10:00
parent bd9b428ff8
commit ec27b01403
2 changed files with 32 additions and 13 deletions

23
main.go
View file

@ -4,8 +4,10 @@ import (
"fmt"
"image"
"image/color"
"io"
"log"
"net/http"
"os"
"github.com/disintegration/imaging"
"github.com/fogleman/gg"
@ -25,13 +27,28 @@ func routeHandler(w http.ResponseWriter, r *http.Request) {
}
func formHandler(w http.ResponseWriter, r *http.Request) {
if err := r.ParseMultipartForm(2048); err != nil {
file, handler, err := r.FormFile("file")
fileName := r.FormValue("file_name")
if err != nil {
panic(err)
}
defer file.Close()
f, err := os.OpenFile(handler.Filename, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
panic(err)
}
defer f.Close()
_, _ = io.WriteString(w, "File "+fileName+" Uploaded successfully")
_, _ = io.Copy(f, file)
if err := r.ParseMultipartForm(8192); err != nil {
fmt.Fprintf(w, "ParseMultipartForm() err: %v", err)
return
}
fmt.Fprintf(w, "POST request successful")
//uncommentfile := r.FormValue("file")
//uncommenttext := r.FormValue("text")
//text := r.FormValue("text")
}

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html class="no-js">
<html>
<head>
<meta charset="utf-8">
@ -11,15 +11,17 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
<body>
<img src="/enemyfelled.png" /></marquee>
<form id=upload enctype="multipart/form-data">
<h2>a dumb lil elden ring generator i made (ALPHA)</h2>
<input type="file" name="file" required></br></br>
<h3>Enter your text</h3>
<input type="text" name="text" id="text" required>
</form>
<center><button type=submit onclick=butts() class="btn btn-primary">Upload</button></center>
<center>
<img src="/enemyfelled.png" /></marquee>
<form id=upload action="/submit" enctype="multipart/form-data">
<h2>a dumb lil elden ring generator i made (ALPHA)</h2>
<input type="file" name="file" required></br></br>
<h3>Enter your text</h3>
<input type="text" name="text" id="text" required>
<button type=submit class="btn btn-primary">Upload</button>
</form>
</center>
<center>
<h4>More options coming soon same with some styling to make it not look like another of my projects</h4>
</center>