Some cleanup
This commit is contained in:
parent
52b7e594f3
commit
d130cfe8e1
|
@ -1,11 +1,11 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{% block title %}{{ sitename }}{% endblock %}</title>
|
<title>{% block title %}{{ sitename }}{% endblock %}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form enctype="multipart/form-data" action="/upload" method="post">
|
<form enctype="multipart/form-data" action="/upload" method="post">
|
||||||
<input type="file" name="file" />
|
<input type="file" name="file" />
|
||||||
<input type="submit" value="upload" />
|
<input type="submit" value="upload" />
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
12
upload.go
12
upload.go
|
@ -77,16 +77,14 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) {
|
||||||
|
|
||||||
upload.Filename = strings.Join([]string{barename, extension}, ".")
|
upload.Filename = strings.Join([]string{barename, extension}, ".")
|
||||||
|
|
||||||
dst, ferr := os.Create(path.Join("files/", upload.Filename))
|
dst, err := os.Create(path.Join("files/", upload.Filename))
|
||||||
defer dst.Close()
|
if err != nil {
|
||||||
if ferr != nil {
|
|
||||||
err = ferr
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer dst.Close()
|
||||||
|
|
||||||
bytes, cerr := io.Copy(dst, upReq.src)
|
bytes, err := io.Copy(dst, upReq.src)
|
||||||
if cerr != nil {
|
if err != nil {
|
||||||
err = cerr
|
|
||||||
return
|
return
|
||||||
} else if bytes == 0 {
|
} else if bytes == 0 {
|
||||||
err = errors.New("Empty file")
|
err = errors.New("Empty file")
|
||||||
|
|
Loading…
Reference in New Issue