Using Compojure, Hiccup and Ring to upload a file

守給你的承諾、 提交于 2019-12-04 09:56:54

The file upload support for Compojure can be found in the multipart-params Ring middleware. Here's some examples of how to use it:

Always have a look at Ring middleware documentation, it is full of great code!

Update: Didn't read your question right the first time! To generate a form like this one:

<form action="/file" method="post" enctype="multipart/form-data">
  <input name="file" type="file" size="20" />
  <input type="submit" name="submit" value="submit" />
</form>

That should do the trick:

[:form {:action "/file" :method "post" :enctype "multipart/form-data"}
 [:input {:name "file" :type "file" :size "20"}]
 [:input {:type "submit" :name "submit" :value "submit"]]

I've done it from memory, so it's untested.

markus
[:input {:type "submit" :name "submit" :value "submit"]]

Missing }

[:input {:type "submit" :name "submit" :value "submit"]}]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!