On Sun, Nov 16, 2008 at 10:46 AM, Justin Walgran <[EMAIL PROTECTED]> wrote:
> I have been puzzling over the best way to upload a file from an HTML > form and have it end up as an attachment to a new CouchDB document. > > Here is what I would like to do: > > 1) User select file using a "file" form element > 2) User clicks the submit button > 3) New CouchDB doc is created > 4) Selected document is POSTed as an attachment to the new CouchDB doc > > One snag is the fact that jquery.couch.DB.saveDoc does not not return > the autogenerated doc id, which makes it impossible to generate the > attachment url. > > The bigger snag is the chaining of the two POSTs together. Based on my > preliminary Googling It does not appear possible to trigger a file > upload from javascript. > > Has anyone tackled this? I believe you have to use an iframe if you want to do it in javascript. This has definitely been tackled -- take a closer look at Futon -- it's in there.