简体   繁体   中英

when i submit form input type=file for send image with php i want redirect to an other page

when i submit form input type=file for send image with php i want redirect to an other page but the file was not send, I want to use "ACTION=index.php" but after having submit the form the page is well redirected but the images are not sent, basically what I want is to send the files and go to the next page, so logically using action you should redirect me directly to index.php it redirect me but without sending me files

 <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="assets\images\id-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="assets\images\id-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="assets\images\Asset171.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>

you can handle this in php file after checking your fields validation:


<?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/");
    }
?>


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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM