使用noir上传图片失败

26 views
Skip to first unread message

Peter Huang

unread,
Jan 14, 2015, 10:27:24 AM1/14/15
to cn-cl...@googlegroups.com
最近在《Web Development with Clojure》
在看到第5章上传图片的例子时,无法正确达到上传图片的目的。
上传页面定义:
(defn upload-page [info]
  (layout/base
   [:h2 "Upload an image"]
   [:p info]  
   (form-to {:enctrype "multipart/form-data"}
            [:post "/upload"]
            (file-upload :file)
            (submit-button "upload"))))
在浏览器中看到的源码:
<!DOCTYPE html>
<html><head><title>Welcome to picture-gallery</title><link href="/css/screen.css" rel="stylesheet" type="text/css"></head><body><h2>Upload an image</h2><p>success-</p><form action="/upload" enctrype="multipart/form-data" method="POST"><input id="file" name="file" type="file"><input type="submit" value="upload"></form></body></html>

可是POST后,request的内容却是这样了:
{:ssl-client-cert nil, :cookies {}, :remote-addr "0:0:0:0:0:0:0:1", :params {:file "DSC01492.JPG"}, :flash nil, :route-params {}, :headers {"origin" "http://localhost:8080", "host" "localhost:8080", "user-agent" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36", "content-type" "application/x-www-form-urlencoded", "content-length" "17", "referer" "http://localhost:8080/upload", "connection" "keep-alive", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "accept-language" "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,zh-TW;q=0.2", "accept-encoding" "gzip,deflate,sdch", "cache-control" "max-age=0"}, :server-port 8080, :content-length 17, :form-params {"file" "DSC01492.JPG"}, :session/key nil, :query-params {}, :content-type "application/x-www-form-urlencoded", :character-encoding nil, :uri "/upload", :server-name "localhost", :query-string nil, :body #, :multipart-params {}, :scheme :http, :request-method :post, :session {}}

请问我哪里做错了吗?
(源码已附,谢谢)

picture-gallery.rar

Lei

unread,
Jan 14, 2015, 2:41:42 PM1/14/15
to cn-cl...@googlegroups.com
拼写错误:{:enctrype "multipart/form-data"}
应该是: {:enctype "multipart/form-data"}

--
中文社区博客:http://blog.clojure.cn/
中文问答网站:http://ask.clojure.cn/
中文邮件列表:https://groups.google.com/d/forum/cn-clojure?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“CN-Clojure”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到cn-clojure+...@googlegroups.com
要发帖到此群组,请发送电子邮件至cn-cl...@googlegroups.com
访问此群组:http://groups.google.com/group/cn-clojure
要查看更多选项,请访问https://groups.google.com/d/optout

Peter Huang

unread,
Jan 15, 2015, 9:14:25 AM1/15/15
to cn-cl...@googlegroups.com
果然是的,多谢了
下次仔细看看再请教

在 2015年1月15日星期四 UTC+8上午3:41:42,Lei写道:
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到cn-clojure+unsubscribe@googlegroups.com
Reply all
Reply to author
Forward
0 new messages