// PostUploadHandler is used to handle a file upload
PostUploadHandler is used to handle a file upload
// PostUploadHandler is used to handle a file upload
func PostUploadHandler(c buffalo.Context) error {
	f, err := c.File("MyFile") 
	if err != nil {
		c.Set("errors", err)
		return errors.WithStack(err)
	}
	widget := &models.Widget{Name: "test_widget", Uploadfile: f}
	tx := c.Value("tx").(*pop.Connection)
	verrs, err := tx.ValidateAndCreate(widget)
	if err != nil {
		c.Set("errors", err)
		return errors.WithStack(err)
	}
	if verrs.HasAny() {
		c.Set("widget", widget)
		c.Set("errors", verrs)
		return c.Render(422, render.R.HTML("/"))
	}
	c.Flash().Add("success", "File was uploaded successfully")
	return c.Redirect(302, "/")
}
func PostUploadHandler ( c buffalo . Context ) error { f , err := c . File ( " " ) if err != nil { c . Set ( " " , err ) return errors . WithStack ( err ) } widget := & models . Widget { Name : " " , Uploadfile : f } tx := c . Value ( " " ) . ( * pop . Connection ) verrs , err := tx . ValidateAndCreate ( widget ) if err != nil { c . Set ( " " , err ) return errors . WithStack ( err ) } if verrs . HasAny ( ) { c . Set ( " " , widget ) c . Set ( " " , verrs ) return c . Render ( 422 , render . R . HTML ( " " ) ) } c . Flash ( ) . Add ( " " , " " ) return c . Redirect ( 302 , " " ) }
PostUploadHandler is used to handle a file upload
PostUploadHandler is used to handle a file upload
// change name - SomeFile // Validate the data from the html form // Make contact available inside the html template // Make the errors available inside the html template // Render again the new.html template that the user can // correct the input. //return c.Render(422, r.HTML("api-examples/upload.html")) // If there are no errors set a success message // and redirect to the home index page