#1273 new

AJAX: patch for contentType when uploading files

Reported by labs | August 17th, 2011 @ 10:29 PM

Hi folks.

Using the "postBody" option on Ajax.Request options I've been able to perform file uploads like:

opts.postBody = new FormData();
opts.postBody.append("my_file", $('my_file').files[0]);
new Ajax.Request(this.SERVER_URL, opts);

BUT ONLY after I changed around the line 1556 to display like this:

if (!this.options['skipContentType']) { 
    headers['Content-type'] = this.options.contentType +
    (this.options.encoding ? '; charset=' + this.options.encoding : '');

Being "skipContentType" a flag in options to prevent Prototype to set the content-type in this case and mess up with the automatic content-type and boundarys generated by the XMLHttpRequest for the upload.

Sharing this so you guys could proper code and hopefully release this on a next build.

[]'s Labs

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket