Created
October 26, 2011 07:31
-
-
Save danjac/1315692 to your computer and use it in GitHub Desktop.
file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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