2
我試圖做一個隱藏的文件上傳到iframe,我卡住了。 什麼似乎不工作是選擇一個文件。 當我取消隱藏窗體控件並使用它們時,一切正常。 如果我使用表單控件來選擇一個文件,然後通過「發送」鏈接提交表單 - 它工作正常。 當我使用選擇文件鏈接時,我可以看到文件控件填滿了我選擇的文件,但提交按鈕不提交表單或文件未上傳。 因此,我無法鏈接那些讓我的文件自動上傳後,我選擇了它。獲取隱藏的輸入類型=文件根據需要工作
請告訴我我做錯了什麼。
<div class="fileuploader">
<form id="fileupload" action="@Url.Action("UploadFile","Publication")"
method="post" enctype="multipart/form-data" target="upload_target" >
style="display:none"
<input id="filetoupload" name="filetoupload" type="file" /><`enter code here`br />
<input id="submitbutton" type="submit" name="submitBtn" value="Upload" />
</form>
<iframe id="upload_target" name="upload_target" src="#" style="width: 0; height: 0;
border: 0px solid #fff;"></iframe>
</div>
<div>
<a href="#" id="choosefile">choose a file</a>
<a href="#" id="send">send</a>
</div>
<script type="text/javascript">
$("#send").click(function(){$("#submitbutton").click();});
$("#choosefile").click(function() {
$("#filetoupload").click();
});
</script>