0

When I try to submit my form everything seems to work, but it doesn't actually work when I add the $ _FILES variable to my PHP file.

This is my code and it doesn't work:

action.php

<?php
if (isset($_FILES['logoUp']['name'][$key])){
   echo 'success form submit';
}

echo $_POST['test'];
?>

form.html

<form id="co-heared4us-form" name="co-heared4us-form" method="post" enctype="multipart/form-data" autocomplete="off">

<input type="file" id="logoUp" name="logoUp[]" accept=".ai, .pdf, .eps, .svg, image/png, image/jpeg, image/jpg" multiple="multiple"/>

<input type="text" name="test" value="test" id="test" />

<input type="submit" value="send" />
</form>

<script>
$("html").on("submit", "form#co-heared4us-form", function(e) {
                  e.preventDefault();

                  $.ajax({
                        type: 'post',
                        url: 'action.php',
                        data: $('form#co-heared4us-form').serialize(),
                        success: function () {
                          alert('form was submitted');
                        }
                  });
                  
                  
        });
</script>

I noticed that if I run the action.php without submit ajax the action.php works correctly even with $ _FILES. How can i do?

Jackom
  • 180
  • 8

0 Answers0