View Full Version : File Upload to the server protected with OAuth

8 Feb 2013, 2:47 PM
Trying to upload a file to the server that requires a OAuth token in the header.

The code is similar to this example: http://dev.sencha.com/deploy/ext-4.0.0/examples/form/file-upload.js but it appears that there is no way to add HTTP headers here, since for file upload it always uses HTML form submit and not AJAX, so headers cannot be changed/added...

Any good work arounds?


11 Feb 2013, 10:03 AM
Detect file upload and look for the token in form data?

11 Feb 2013, 11:15 AM
From what I understand, current implementation of the form submission will always use HTML instead of Ajax when file upload is needed, so is there a method, event, property that we need to change to switch it to Ajax? If not, is there a way to get file contents and implement submission as a separate "custom" call?

In other words, here is the code for submit from the sample:

buttons: [
{ text: 'Save',
handler: function()
{ var form = this.up('form').getForm();
{ form.submit(
{ url: 'file-upload.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o)
{ msg('Success', 'Processed file "' + o.result.file + '" on the server');
} }); } } }

Adding "headers": "Test:test" will not work here once form has a field of the type file...

(Not sure I am very clear here about the problem...)