-3
I have a form in which I can send a single file, by a file field, and store it in the database.
However, I need to be able to send more than one file through the form and store them in the database.
Below is my code for you to better understand my problem.
//CÓDIGO PARA PREENCHIMENTO DA LISTA COM OS DADOS DA PESQUISA 
$(document).ready(function() {
      $('#formulario-atividade-extra-cliente').submit(function(e) {
        e.preventDefault();
        var formulario_extra = $(this);
        var retorno = inserirFormulario(formulario_extra);
      });
      function inserirFormulario(dados) {
        arquivo = $("#arquivo-cliente");
        arquivo = arquivo[0];
        file = arquivo.files;
        file = file[0];
        // Apenas 2MB é permitido
        if (file != undefined) {
          if (file.size > 2 * 1024 * 1024) {
            alert("Arquivo excede os 2 Megas");
            return false;
          }
        }
        var formul = $('#formulario-atividade-extra-cliente')[0];
        var data = new FormData(formul);
        $.ajax({
          type: "POST",
          enctype: 'multipart/form-data',
          url: "../banco/banco-crm/pagina-atividade-extra-cliente/update-cliente.php",
          data: data,
          processData: false,
          contentType: false,
          cache: false,
          timeout: 600000,
        }).done(function(data) {
          if (data == "atividadecriadacomsucesso") {
            $('#modal-confirmacao').modal('show');
            //Limpar o formulário
            $('#formulario-atividade-extra-cliente').each(function() {
              this.reset();
            });
          } else {
            $('#modal-negacao').modal('show');
            console.log(data);
            //Limpar o formulário
            $('#formulario-atividade-extra-cliente').each(function() {
              this.reset();
            });
          }
        }).fail(function() {
          alert("Ativou o fail do AJAX");
        }).always(function(data) {
          console.log(data);
        });
      }
<form id="formulario-atividade-extra-cliente" enctype="multipart/form-data">
   
  <!-- CAMPO DETALHES -->
 
    <label for="destalhes-atividade-cliente">Detalhes</label>   
      <textarea name="detalhes-atividade-cliente" id="detalhes-atividade-cliente" style="resize:none" maxlength="500" rows="7" placeholder="Descreva detalhes sobre a atividade que será realizada"></textarea>
  <!-- Campo anexar Arquivos -->
    <label for="arquivo-cliente">Enviar Arquivos:</label>
      <input class="form-control form-control-sm" type="file" name="arquivo-cliente" id="arquivo-cliente" multiple>
    <input id="criar-atividade-extra" type="submit">
    
</form>
<!-- Código PHP COM O CÓDIGO DE RECEBIMENTO DOS DADOS DO FORM (update-cliente.php -->
<?php
				
	date_default_timezone_set('Etc/GMT+3');
	setlocale(LC_ALL, "", "pt_BR.utf-8");
	
	//UPLOAD DE ARQUIVO  VINDO DO FORMULÁRIO
	if(!empty($_FILES["arquivo-cliente"]["tmp_name"]))
	{
		$file_tmp = $_FILES["arquivo-cliente"]["tmp_name"]; //NOME DO ARQUIVO NO COMPUTADOR
		$file_name = $_FILES["arquivo-cliente"]["name"];
		$file_size = $_FILES["arquivo-cliente"]["size"]; 
		$file_type = $_FILES["arquivo-cliente"]["type"];
		$partes = explode(".", $file_name);
		$extensao = end($partes);
		$binario = file_get_contents($file_tmp); // evitamos erro de sintaxe do MySQL
		$binario = mysqli_real_escape_string($conecta, $binario);
		//FIM DO UPLOAD DE ARQUIVO
	}	
	
	
	
	//PREENCHE AS VARIÁVEIS COM OS DADOS VINDOS DOS CAMPOS DO FORMULÁRIO
	
	$detalhes_atividade_cliente   = filter_input(INPUT_POST, 'detalhes-atividade-cliente', FILTER_SANITIZE_STRING); 
 
	
	$designou_atividade   = "CLIENTE";
	$cod_cliente = $_SESSION["COD"];
	$tributacao_cliente = $_SESSION["TRIBUTACAO"];
	$empresa_cliente = $_SESSION["EMPRESA"];
	
	
	//As duas linhas abaixo, pegando a data de hoje + 2 dias
	$data = date("Y-m-d");
	$data_de_vencimento =  date('Y-m-d', strtotime("+2 days",strtotime($data))); 
	
	
	//CONFIGURANDO A VARIÁVEL CONFERENCIA
	
	if(!empty($_FILES["arquivo-cliente"]["tmp_name"]))
	{
		$conferencia_cliente = "A CONFERIR";
		$possui_arquivos_cliente = "S";
	}
	else
	{
		$conferencia_cliente = "NÃO POSSUI ARQUIVO";
		$possui_arquivos_cliente = "N";
	}
	
	$insert_atividade_cliente = "INSERT INTO tbl_atividades(COD, EMPRESAS, TRIBUTACAO, RESPONSAVEL, DESIGNADOR, DT_VENCIMENTO, STATUS, FEEDBACK, EXTRA_URGENTE_COMUM, VISUALIZADO, ATUALIZADO, ARQUIVO, EMPRESA_ORIGEM, CONFERENCIA) 
	VALUES('$cod_cliente','$empresa_cliente','$tributacao_cliente','NAO ATRIBUIDO','$designou_atividade','$data_de_vencimento','PENDENTE','$detalhes_atividade_cliente','E','N','S','$possui_arquivos_cliente','NAO ATRIBUIDO','$conferencia_cliente')";
  
	$result_insert_atividades_cliente = mysqli_query($conecta, $insert_atividade_cliente);  	
	
?>
I tried to reduce the code to only sample the part that really matters. Thank you!
Some Feedback for Question Improvement ?
– Gato de Schrödinger