Jquery ajax将多个图像和文本发布到php-->;mysql

Jquery ajax将多个图像和文本发布到php-->;mysql,jquery,Jquery,所以我有一个表单,它使用jquery$.ajax调用php脚本。我的问题是我还没有找到任何方法来发送文本输入和文件输入或图像。我可以发送文本,只是图像,而不是图像 我得到的是: Javascript: 否则{ $.ajax({ type: 'POST', url: 'test1.php', cache: false, data: $(".contact_form").serialize

所以我有一个表单,它使用jquery$.ajax调用php脚本。我的问题是我还没有找到任何方法来发送文本输入和文件输入或图像。我可以发送文本,只是图像,而不是图像

我得到的是:

Javascript:

否则{

        $.ajax({
            type: 'POST',
            url: 'test1.php',
            cache: false,
            data: $(".contact_form").serializeArray(),
            success: function (data) {
                if (data == "error") {
                    $('.success_box').hide();
                    $('.error_box').show();
                }
                else {
                    $('#sname').val('');
                    $('#email').val('');
                    $('#title').val('');
                    $('#message').val('');
                    $('#photo1').val('');
                    $('#photo2').val('');
                    $('.error_box').hide();
                    $('.success_box').show();
                }
            }
        });
    }
PHP:

我个人用过。

另外,请查看本文:

此外,这里还有一些插件:
    <?php
$sname=$_POST['sname'];
$email=$_POST['email'];
$title=$_POST['title'];
$description=$_POST['message'];
$photo1=$_FILES['photo1']['tmp_name'];
$photo2=$_FILES['photo2']['tmp_name'];

$link = mysql_connect("localhost","root","root");

if (!$link) {
    die(mysql_error());
    echo('link stop');  
}
$db = mysql_select_db("test");

if (!$db) {
    die(mysql_error()); 
    echo('braaahh');
}   
    $imge1 = addslashes(file_get_contents($_FILES['photo1']['tmp_name']));
    $imge2 = addslashes(file_get_contents($_FILES['photo2']['tmp_name']));

if (!mysql_query("INSERT INTO forSale VALUES ('', '$sname', '$email', '$title',         '$description', '$imge1', '$imge2')")) {
    die(mysql_error());
    echo("help");
}   

mysql_close();
    ?>