如何将输入数据从ajax发送到php

时间:2015-02-15 19:58:31

标签: php mysql

我尝试将数据从ajax发送到php我可以将图像保存在数据库中,但其他输入数据不保存

var formData = new FormData($("#myForm")[0]);

    //alert( formData );
    console.log(replaceWin);        
    $.ajax({
      type: "POST",
      url: "map_process.php",
      data: formData,
      cache: false,
    contentType: false,
    processData: false,
    async: false,

      success:function(data){
            replaceWin.html(data); //replace info window with new html
            Marker.setDraggable(false); //set marker to fixed
            Marker.setIcon('icons/pin_blue.png'); //replace icon
        },
        error:function (xhr, ajaxOptions, thrownError){
            alert(thrownError); //throw any errors
        }
    });

page.php文件:

$mLatLang   = explode(',',$_POST["latlang"]);
$mLat       = filter_var($mLatLang[0], FILTER_VALIDATE_FLOAT);
$mLng       = filter_var($mLatLang[1], FILTER_VALIDATE_FLOAT);
$mdes       = filter_var($_POST["description"], FILTER_SANITIZE_STRING);
$mType      = filter_var($_POST["type"], FILTER_SANITIZE_STRING);   

        $uploadDir = 'images/';
        $fileName = $_FILES['image']['name'];
        $tmpName  = $_FILES['image']['tmp_name'];
        $fileSize = $_FILES['image']['size'];
        $fileType = $_FILES['image']['type'];
        $filePath = $uploadDir . $fileName;
        move_uploaded_file($tmpName, $filePath);
        $image = basename( $mImage );

任何想法我能做些什么来保存其他数据

0 个答案:

没有答案