当我用php提交表单输入type=文件以发送图像时,我想重定向到其他页面,但文件没有发送,我想使用"ACTION=index.php";但是在提交表单后,页面被很好地重定向,但图像没有被发送,基本上我想要的是发送文件并转到下一页,所以从逻辑上讲,使用操作你应该将我直接重定向到index.php,它重定向我,但不发送文件
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
$('input[type="file"]').on('change', function() {
var filename = $(this).val().split('\').pop();
$(this).next().find('span').html(filename);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<form method="POST" enctype="multipart/form-data" ACTION=index.php>
<div class="containerid">
<div class="cardid">
<div class="imgid">
<img class="idfront"src="assetsimagesid-card-front.png" alt="">
</div>
<input type="file" name="recto" id="recto" class="btnsend" />
<label for="recto" class="labelbtn"><span>Choisir le Recto</span></label>
</div>
<div class="cardid">
<div class="imgid">
<img class="idfront"src="assetsimagesid-card-back.png" alt="">
</div>
<input type="file" name="verso" id="verso" class="btnsend" />
<label for="verso" class="labelbtn"><span>Choisir le Verso</span></label>
</div>
<div class="cardid">
<div class="imgid">
<img class="idfront"src="assetsimagesAsset171.png" alt="">
</div>
<input type="file" name="selfie" id="selfie" class="btnsend" />
<label for="selfie" class="labelbtn"><span>Choisir le Selfie</span></label>
</div>
</div><br>
<input type="submit" name="submit" class="sendall"/>
</form>
在检查字段验证后,您可以在php文件中处理此问题:
<?php
if(isset($_POST['submit'])){
// Fetching variables of the form which travels in URL
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$address = $_POST['address'];
if($name !=''&& $email !=''&& $contact !=''&& $address !='')
{
// To redirect form on a particular page
header("Location:https://www.formget.com/app/");
}
?>