[英]Jquery,php form not sending post data with .submit()
我有一個上傳頁面,其中包含一個不可見的輸入,當您單擊圖片時會激活,選擇文件后,我希望javascript將表單提交到另一頁,但在另一頁上,$ _ FILES ['file']為空
我的上傳頁面:
形成:
<form style="visibility: hidden;" id="target" method='POST' action="otherpage.php">
<input type="file" id="file" value="Go" name="file" />
</form>
javascript
function updatebillede() {
$('input[type="file"]').click();
};
$(document).ready(function() {
$('input[type="file"]').change(function() {
var $this = $(this);
if ($this.val() != '') {
$("#target").submit();
} else {
alert("Error");
}
});
});
</script>
我的另一頁
<?php print_r($_FILES['file']); ?>
您需要在表單屬性中添加enctype='multipart/form-data'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.