tag:blogger.com,1999:blog-581197352358126527.post570625861688300019..comments2024-03-28T00:32:25.959-07:00Comments on japh(r) by Chris Strom: How to Upload Files in CouchAppAnonymoushttp://www.blogger.com/profile/00135361916531185929noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-581197352358126527.post-6232994986464905262012-11-14T12:12:05.172-08:002012-11-14T12:12:05.172-08:00Here is a very simple example with good comments t...Here is a very simple example with good comments that you can load into your CouchDB. https://gist.github.com/4074427Anonymoushttps://www.blogger.com/profile/12303132093676535160noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-51676207785603584522012-10-11T19:53:13.415-07:002012-10-11T19:53:13.415-07:00This is not working for me. I get the error: '...This is not working for me. I get the error: '{"error":"method_not_allowed","reason":"Only DELETE,GET,HEAD,PUT allowed"}'. Here is my entire html document which I put on couchdb.<br />I was however forced to remove the usual HTML brackets because HTML is not allowed in comments for some reason.<br />html<br />head<br />script src="http://code.jquery.com/jquery-1.8.2.min.js"/script<br />script src="http://localhost:5984/_utils/script/jquery.js?1.2.6"/script<br />script src="http://localhost:5984/_utils/script/jquery.couch.js?0.8.0"/script<br />script src="http://localhost:5984/_utils/script/jquery.form.js?0.9.0"/script<br />/head<br />body<br />form method="post"<br />input type="file" id="recipe-upload"<br />input type="submit"<br />/form<br />script type="text/javascript" charset="utf-8"<br />$("#recipe-upload").submit(function(e) { // invoke callback on submit<br /> e.preventDefault();<br /> var data = {};<br /> $.each($("form :input").serializeArray(), function(i, field) {<br /> data[field.name] = field.value;<br /> });<br /> $("form :file").each(function() {<br /> data[this.name] = this.value; // file inputs need special handling<br /> });<br /><br /> if (!data._attachments || data._attachments.length == 0) {<br /> alert("Please select a file to upload.");<br /> return;<br /> }<br /><br /> $(this).ajaxSubmit({<br /> url: "/%= dbname %/%= docid %",<br /> success: function(resp) {<br /> $('#saved').fadeIn().animate({ opacity: 1.0 },3000).fadeOut();<br /> alert("success");<br /> }<br /> });<br />});<br />/script<br />/body<br />/html<br />'Andrewhttps://www.blogger.com/profile/16642082037231171375noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-72361838947417062272010-03-02T13:28:15.876-08:002010-03-02T13:28:15.876-08:00Small addition to a truly purposefull and informat...Small addition to a truly purposefull and informative blog entry. This tells the user that the update has failed- firebug console message of success and fail<br />(these messages are within pre tags which are not allowed in your blog comments)<br /><br />{"ok":true,"id":"test","rev":"25-1223e10f2bd556a67665bc9a0ebae738"}<br /><br />{"error":"conflict","reason":"Document update conflict."}<br /><br /><br /><br /> $(this).ajaxSubmit({<br /> url: "/<%= dbname %>/<%= docid %>",<br /> success: function(resp) {<br /> if(resp.match("ok")){ $('#saved').fadeIn().animate({ opacity: 1.0 },3000).fadeOut();}<br /> else if(resp.match("error")){ $('#failed').fadeIn().animate({ opacity: 1.0 },3000).fadeOut();} <br /> }dmwmoccamhttps://www.blogger.com/profile/15699720495830754352noreply@blogger.com