Created
November 11, 2012 21:10
-
-
Save toranb/4056283 to your computer and use it in GitHub Desktop.
cross domain multipart post for file upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment