Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
cross domain multipart post for file upload
var iframeId = 'somethingUnique';
var url = '';
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment