I'm trying to allow the user to upload an image with an HTML form, and on 
the form submit, the POST action interacts with my Go server-side code. How 
do I get the file path of the uploaded image in my Go code? 

I had the following code in my HTML:

<input type="file" accept="image/*" id="file-input" name="upload">

and the following code in my Go:
                file, h, err := r.FormFile("file-input")

if err != nil{
    log.Println("err: ",err)
    http.Error(w,"Error Uploading",http.StatusInternalServerError)
    return
}

defer file.Close()

fmt.Println("filename: ", h.Filename)

// fill input struct
image := Image {
Base64: "\"'\"$(base64 " + h.Filename + ")\"'\"",
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to