public
Created

cross domain multipart post for file upload

  • Download Gist
iframe-http-post.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13
var iframeId = 'somethingUnique';
var url = 'http://someotherdomain.com';
var $form = $('<form>');
$form.attr('id', 'foo');
$form.attr('action', url);
$('<iframe name="' + iframeId + '" id="' + iframeId + '" />').appendTo('body');
$("#" + iframeId).attr('style', 'display: none;');
$("#" + iframeId).append($form);
$form.attr('target', iframeId);
$form.attr('method', 'POST');
$form.attr('enctype', 'multipart/form-data');
$form.attr('encoding', 'multipart/form-data');
$form.submit();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.