Skip to content

Instantly share code, notes, and snippets.

@danjac
Created October 26, 2011 07:31
Show Gist options
  • Save danjac/1315692 to your computer and use it in GitHub Desktop.
Save danjac/1315692 to your computer and use it in GitHub Desktop.
file upload
(ns file-uploadr.views.upload
(:require [file-uploadr.views.common :as common]
[noir.response :as res]
[noir.content.pages :as pages])
(:use noir.core
hiccup.core
hiccup.page-helpers
hiccup.form-helpers))
(defpage "/" []
(common/layout
(form-to {:enctype "multipart/form-data"}
[:post "/upload"]
(label :file "File to upload")
(file-upload :file)
[:br]
(submit-button "Upload"))))
(defpage [:post "/upload"] {:keys [file]}
(if-not (= "0" (:size file))
(res/redirect "/success")
(res/redirect "/fail")))
(defpage "/success" []
(common/layout
[:p "File upload successful!"]))
(defpage "/fail" []
(common/layout
[:p "File upload FAIL!"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment