On 11 January 2011 11:28, Jani Tiainen <rede...@gmail.com> wrote:
> On Monday 10 January 2011 16:05:13 Mauro wrote:
>> On 23 Dic 2010, 23:12, Paul Osman <p...@eval.ca> wrote:
>> > On Thu, Dec 23, 2010 at 9:39 AM, Mauro <mdrio1...@gmail.com> wrote:
>> > > Hello,
>> > > is it possible to upload files via ajax?
>> > >
>> > > I would like to upload multiple files in my application but i have the
>> > > following exception:
>> > >
>> > > MultiPartParserError: Invalid boundary in multipart: None
>> > >
>> > > I'm using django 1.1.
>> > > The ajax request has the content type header set as mulitpart/form-
>> > > data
>> >
>> > This was recently posted to the Mozilla Webdev blog. Might help you:
>> >
>> > http://blog.mozilla.com/webdev/2010/09/17/django-and-ajax-image-uploads/
>> >
>> > -Paul
>>
>> Hi, thanks for replying, but would like to choose the files at once
>> and then upload them one by one (without flash, only html).  Using an
>> ajax request, django returns the MultiParseError. Moreover i try to
>> user request._post_raw_data, but i would like to send also some other
>> informations together with the files, and i do not to retrieve them
>> from raw_data,
>> Any other idea?
>
> First at all this is not possible. It is not possible send files using ajax.

Yes you can: http://www.w3.org/TR/XMLHttpRequest2/ This only works
fully in Firefox 4 and Webkit browsers (last I tested). Firefox 3.6
lacks the FormData object, but has an API to read files from
JavaScript, so you can form-encode the data yourself and use
xhr.send(). An almost complete implementation can be seen here:
http://code.google.com/p/jquery-html5-upload/.

>
> But you can use ajaxy like approach. Common way is to create (invisible)
> iframe where you clone original form and just do normal post there.
>
> When iframe loads you can post back response from server to your application.
> It's not fully ajax but as close as it can get without using flash.

I call this HTML4 fallback. I have a whole jQuery plugin that
transparently uses an IFrame if the user's browser doesn't have any of
required HTML5 capabilities. It lets you upload multiply files with
additional POST data (e.g. file description, tags). Sadly, I can't
open-source it just yet.

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to