I have an upload page with an invisible input that i acitvated when you click on a picture and after a file is selected i want javascript to submit the form to another page but on the other page $_FILES['file'] is empty
my upload page:
form:
<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>
my other page
<?php print_r($_FILES['file']); ?>
您需要在表单属性中添加enctype='multipart/form-data'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.