Browse Source

Some cleanup

pull/3/head
andreimarcu 9 years ago
parent
commit
d130cfe8e1
  1. 4
      templates/base.html
  2. 4
      templates/index.html
  3. 12
      upload.go

4
templates/base.html

@ -1,11 +1,11 @@
<html>
<head>
<title>{% block title %}{{ sitename }}{% endblock %}</title>
<title>{% block title %}{{ sitename }}{% endblock %}</title>
</head>
<body>
<div>
{% block content %}{% endblock %}
{% block content %}{% endblock %}
</div>

4
templates/index.html

@ -2,7 +2,7 @@
{% block content %}
<form enctype="multipart/form-data" action="/upload" method="post">
<input type="file" name="file" />
<input type="submit" value="upload" />
<input type="file" name="file" />
<input type="submit" value="upload" />
</form>
{% endblock %}

12
upload.go

@ -77,16 +77,14 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) {
upload.Filename = strings.Join([]string{barename, extension}, ".")
dst, ferr := os.Create(path.Join("files/", upload.Filename))
defer dst.Close()
if ferr != nil {
err = ferr
dst, err := os.Create(path.Join("files/", upload.Filename))
if err != nil {
return
}
defer dst.Close()
bytes, cerr := io.Copy(dst, upReq.src)
if cerr != nil {
err = cerr
bytes, err := io.Copy(dst, upReq.src)
if err != nil {
return
} else if bytes == 0 {
err = errors.New("Empty file")

Loading…
Cancel
Save