The load
event is firing (confirm by placing an alert inside of your load event). However, you are not appending content to the iframe
properly:
$iframe.load(function() {
var $uploadForm = $("<form target='" + iframeName + "' action='" + options.postUrl + "' method='post' enctype='multipart/form-data' />");
$iframe.contents().find("body").append($uploadForm);
$uploadForm.append($("<input type='file' value='" + options.file + "' />"));
if (options.selectFile === true) {
$uploadForm.find("input").click();
}
});
Note the call to .contents()
before the append
call.
Additionally, I don't believe it's possible to programmatically launch a file input's browse functionality (confirmed by this question).