This is a common problem i had often. This blog post helped me a lot
though: http://japhr.blogspot.com/2010/02/how-to-upload-files-in-couchapp.html?m=0
The trick is to upload your data in two steps: first saveDoc() your
json doc (all the data except the file). Then use ajaxSubmit() to
upload the file.
For the file upload with ajaxSubmit() i made best experience with
having an own form with at least two fields: one called "_attachments"
(type "file") and one called "_rev" (type "hidden" or "text") which
contains the latest document revision. The url passed to ajaxSubmit()
would be the document url (http://host/db/doc).
If you first save your data with saveDoc you'll receive this latest
rev automatically in the response. This allows one straight process
where you start the file upload in the success-callback of the
saveDoc()-call - so you can ensure that you only upload the file if
your other data has been saved sucesssfully.
Good luck!
Dominique
> --
> You received this message because you are subscribed to the Google Groups "CouchApp" group.
> To post to this group, send email to couc...@googlegroups.com.
> To unsubscribe from this group, send email to couchapp+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/couchapp?hl=en.
>
Nils.
________________________________________
Van: couc...@googlegroups.com [couc...@googlegroups.com] namens Dominique Sandoz [dominiqu...@gmail.com]
Verzonden: vrijdag 3 februari 2012 22:33
Aan: couc...@googlegroups.com
Onderwerp: Re: how to create attachments using jquery.couch.js
Hi Alexander
Good luck!
Dominique
------------------------------------------------------------------------
VPRO www.vpro.nl
------------------------------------------------------------------------
<script src="/_utils/script/jquery.form.js"></script
sorry, i forgot about this one...HTH
Ollie
--
@ollicle
--
You received this message because you are subscribed to the Google Groups "CouchApp" group.
To view this discussion on the web visit https://groups.google.com/d/msg/couchapp/-/iqGHsmXYr0wJ.