ImはjQueryを使って、ファイルのアップロードを構築するが、Imは、フォームの属性を設定しようとしているjQueryのエラーを取得:jQueryのiframeのファイルアップロード
$(document).ready(function() {
$("#formsubmit").click(function() {
var iframe = $('<iframe name="postframe" id="postframe" class="hidden" src="about:none" />');
$('div#iframe').append(iframe);
$('#theuploadform').attr("action", "/ajax/user.asmx/Upload")
$('#theuploadform').attr("method", "post")
$('#theuploadform').attr("userfile", $('#userfile').val())
$('#theuploadform').attr("enctype", "multipart/form-data")
$('#theuploadform').attr("encoding", "multipart/form-data")
$('#theuploadform').attr("target", "postframe")
$('#theuploadform').submit();
//need to get contents of the iframe
$("#postframe").load(
function() {
iframeContents = $("iframe")[0].contentDocument.body.innerHTML;
$("div#textarea").html(iframeContents);
}
);
}
);
<div id="uploadform">
<form id="theuploadform" action="">
<input id="userfile" name="userfile" size="50" type="file" />
<input id="formsubmit" type="submit" value="Send File" />
</form>
</div>
<div id="iframe" style="width: 0px; height: 0px; display: none;">
</div>
<div id="textarea">
</div>
を使用してファイルをアップロードするには良いプラグインですか?セキュリティ上の理由から、ブラウザは実際にはファイル入力の値にアクセスできません。戻り値は、いくつかの偽のパス。 –
あなたは間違っています、あなたは値を読むことはできますが、それを変更することはできません。 –
値は何を返しますか?私は値を返すと言っていましたが、ファイルへの実際のパスではありません。 –