私は書籍web development with clojure, 2nd editionのサンプルコードに従っており、Googleクローズによるファイルのアップロードに問題があります。cljs + luminusフレームワーク:Googleクローズによるファイルアップロード
私はSwaggerを使ってファイルのアップロードをテストしました。それは200 okです。私はこのエラーがアップロードファイルからだと思います!機能(下記参照)。
しかし、私はclosure api docを見て、私は正しい機能を使用するようです。
それは動作しません。だから、なぜ私が困って、私にはわからないた...
私は誰かhelp.Hereは私のコード(私は、UIコンポーネントのセマンティック-UIを使用)である必要があります。
(defn upload-file! [upload-form-id status]
(reset! status nil)
(let [io (IframeIo.)]
(gev/listen
io goog.net.EventType.SUCCESS
#(reset! status [c/success-message "file uploaded successfully"]))
(gev/listen
io goog.net.EventType.ERROR
#(reset! status [c/warning-message "failed to upload the file"]))
(.setErrorChecker io #(= "error" (.getResponseText io)))
(.sendFromForm io (.getElementById js/document upload-form-id) "/upload")))
(defn upload-form []
(let [status (atom nil)
form-id "upload-form"]
(fn []
[c/modal
[:div "Upload File"]
[:div
(when @status @status)
[:div.ui.form
{:id form-id
:enc-type "multipart/form-data"
:method "POST"}
[:label {:for "file"} "select an image for upload"]
[:input {:id "file"
:name "file"
:type "file"}]]]
[:div
[:button.ui.primary.button
{:on-click #(upload-file! form-id status)}
"upload"]
[:button.ui.red.button
{:on-click #(do
(.modal (js/$ ".ui.modal") "hide")
(reset! status nil))}
"Cancel"]]
"upload"])))
コンポーネント:
(defn modal [header content footer id]
[:div.ui.modal
{:id id}
[:div.header header]
[:div.content content]
[:div.actions footer]])
(defn success-message [content]
[:div.ui.green.message
[:div.header content]])
それは私の誤りだ....私はそれは、私が入力する必要があります見つけdiv.ui.form 。この質問を申し訳ありません。 – g1eny0ung
あなた自身の質問に答えることができ、これを解決済みとすることができます:http://stackoverflow.com/help/self-answer – n2o
リマインダー@ n2oをありがとう、私はそれに答えるでしょう^ _ ^最初は文章の誤りだと思って答えなくてもいいですが、あなたが正しいです、私はそれを解決したものとしてマークするべきです。 – g1eny0ung