mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: improve examples/vweb/file_upload
This commit is contained in:
@ -2,9 +2,7 @@ module main
|
||||
|
||||
import vweb
|
||||
|
||||
const (
|
||||
port = 8082
|
||||
)
|
||||
const port = 8082
|
||||
|
||||
struct App {
|
||||
vweb.Context
|
||||
@ -20,13 +18,20 @@ pub fn (mut app App) index() vweb.Result {
|
||||
|
||||
['/upload'; post]
|
||||
pub fn (mut app App) upload() vweb.Result {
|
||||
dump(app.form)
|
||||
dump(app.files)
|
||||
fdata := app.files['upfile']
|
||||
|
||||
mut files := []vweb.RawHtml{}
|
||||
|
||||
for d in fdata {
|
||||
files << d.data.replace_each(['\n', '<br>', '\n\r', '<br>', '\t', ' ', ' ', ' '])
|
||||
}
|
||||
|
||||
return $vweb.html()
|
||||
}
|
||||
|
||||
['/submit'; post]
|
||||
pub fn (mut app App) submit() vweb.Result {
|
||||
dump(app.form)
|
||||
form_data := app.form.clone()
|
||||
return $vweb.html()
|
||||
}
|
||||
|
Reference in New Issue
Block a user