From 185b683c0f24d28c30fddd764724c8d828bda10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= Date: Fri, 8 Aug 2014 14:50:47 +0200 Subject: [PATCH] Add X-Requested-With: IFrame to iframe transport This is ported from the jquery-fileupload-rails gem, which uses the header to detect iframe transport uploads in server middleware. --- js/jquery.iframe-transport.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/jquery.iframe-transport.js b/js/jquery.iframe-transport.js index 8d64b591b..2874e6cc5 100644 --- a/js/jquery.iframe-transport.js +++ b/js/jquery.iframe-transport.js @@ -119,6 +119,13 @@ .val(field.value) .appendTo(form); }); + // Add a hidden `X-Requested-With` field with the value `IFrame` to the + // form, to help server-side code to determine that the upload happened + // through this transport. + $('') + .prop('name', 'X-Requested-With') + .val('IFrame') + .appendTo(form); } if (options.fileInput && options.fileInput.length && options.type === 'POST') {