JavaScript How to submit a form with input image into modal Bootstrap? submit form with javascript,submit form with jquery,submit form

I have a modal form using bootstrap. The form contains some text inputs and a image input.

I submit the form with ajax, and all data is received at the PHP file correctly. Alas, the image isn't being uploaded.

What is my code problem?

<script>
    $(document).ready(function () {
        $("input#submit").click(function(){
            $.ajax({
                type: "POST",
                url: "insert.php", 
                data: $('form.contact').serialize(),             
                success: function(msg){
                    $("#th").html(msg)                 
                    $("#form-content").modal('hide');  
                    $("#pro").html(content);
                },
                error: function(){
                    alert("failure");
                }
            });
        });
    });
</script>

The form:

 <form class="contact" name="contact" enctype="multipart/form-data">

      <label for="inputNombre" class="sr-only">Título</label>
      <input id="inputNombre" name="inputNombre" class="form-control" placeholder="Título" required="TRUE" autofocus="" type="text">
      <br> 
       ....
      <div class="upload_pic1 inline">
           <input id="imagen" name="imagen" type="file">
      </div>
 <div class="modal-footer">
    <a target='_blank' href="#" class="btn" data-dismiss="modal">Cerrar</a>
    <input id="submit" class="btn btn-success" type="submit" value="Crear">
    </div>
    </div>

    </form>

EDIT:

insert.php

 <?php

session_start();
if (!isset($_SESSION["name"]) && $_SESSION["name"] == "") {
    // user already logged in the site
    header("location: Login.html");
}  

require_once('funt.php');
conectar('localhost', 'root', '', 'db');

if (isset($_POST['inputNombre'])) {
    $nombre = strip_tags($_POST['inputNombre']);
    ....
    //Here the var imagen     
    if(is_uploaded_file($_FILES['imagen']['tmp_name'])){
        $rutaEnServidor='imagenes';
        $rutaTemporal=$_FILES['imagen']['tmp_name'];
        $nombreImagen=$_FILES['imagen']['name'];
        $rutaDestino=$rutaEnServidor.'/'.$nombreImagen;
        move_uploaded_file($rutaTemporal,$rutaDestino);
    } else {   //Always enter here, so is not uploaded
         $rutaEnServidor='imagenes';
         $rutaTemporal='/noPicture.png';
         $rutaDestino=$rutaEnServidor.'/noPicture.png';
         move_uploaded_file($rutaTemporal,$rutaDestino);
     }
 ...

How can I change this and upload the picture with all data in form?

Answer:1

Basically I'm trying to copy data from <input>s on one tab and then paste it into a form <input>s on another tab using a chrome extension. The part that I'm having trouble with figuring ...

Basically I'm trying to copy data from <input>s on one tab and then paste it into a form <input>s on another tab using a chrome extension. The part that I'm having trouble with figuring ...

I'v been following a few walkthroughs on how to implement d3 charts in an angular application. Basically, Im trying to implement the following d3 chart into my custom angular directive ('workHistory')....

I'v been following a few walkthroughs on how to implement d3 charts in an angular application. Basically, Im trying to implement the following d3 chart into my custom angular directive ('workHistory')....

I am using D3 v4. I have a bar graph created with an x-axis using scaleBand(). Now, I have created a y-axis but my issue is that no matter how I position it, it is cutting into the actual bars of ...

I am using D3 v4. I have a bar graph created with an x-axis using scaleBand(). Now, I have created a y-axis but my issue is that no matter how I position it, it is cutting into the actual bars of ...

I'm using casperJS to try to get a screenshot of a DOM element using captureSelector, but the quality of the screenshot is really poor, but when capturing full screenshot using capture it works ...

I'm using casperJS to try to get a screenshot of a DOM element using captureSelector, but the quality of the screenshot is really poor, but when capturing full screenshot using capture it works ...