// AfterCreate gets run every time after you save widget to database
AfterCreate gets run every time after you save widget to database
// AfterCreate gets run every time after you save widget to database
func (w *Widget) AfterCreate(tx *pop.Connection) error {
	if !w.Uploadfile.Valid() {
		return nil
	}
	dir := filepath.Join(".", "uploads")
	if err := os.MkdirAll(dir, 0755); err != nil {
		return errors.WithStack(err)
	}
	f, err := os.Create(filepath.Join(dir, w.Uploadfile.Filename))
	if err != nil {
		return errors.WithStack(err)
	}
	defer f.Close()
	_, err = io.Copy(f, w.Uploadfile)
	return err
}
func ( w * Widget ) AfterCreate ( tx * pop . Connection ) error { if ! w . Uploadfile . Valid ( ) { return nil } dir := filepath . Join ( " " , " " ) if err := os . MkdirAll ( dir , 0755 ) ; err != nil { return errors . WithStack ( err ) } f , err := os . Create ( filepath . Join ( dir , w . Uploadfile . Filename ) ) if err != nil { return errors . WithStack ( err ) } defer f . Close ( ) _ , err = io . Copy ( f , w . Uploadfile ) return err }
AfterCreate gets run every time after you save widget to database
AfterCreate gets run every time after you save widget to database