Javascript php&;mysql和ajax(将图像插入crud应用程序)

Javascript php&;mysql和ajax(将图像插入crud应用程序),javascript,php,jquery,html,Javascript,Php,Jquery,Html,我需要在这里添加图像字段,但我不知道怎么做,我添加了一些文本字段,但我无法添加图像` <div class="form-group"> <label for="address">Thired step</label> <input type="text" id="address" placeholder="Thired step" class="form-control"/> </div> <div class="f

我需要在这里添加图像字段,但我不知道怎么做,我添加了一些文本字段,但我无法添加图像`

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`
我包括在我的项目中的所有文件,请给我什么是我需要做的修改添加图像和完成这个项目

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`

`

我真的不知道你想在这里完成什么。同时取消对表单标记的注释

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`
<form method="POST" id="image_uploader" enctype="multipart/form-data">
然后换成,

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`
    $.ajax({
        type: "POST",
        url: "ajax/addRecord.php",
        data: formData,
        //use contentType, processData for sure.
        contentType: false,
        processData: false,
        beforeSend: function() {
            //you can add a loading icon or loading message to tell your users something is happening
        },
        success: function(msg) {
            //hide modal on success and load
// close the popup
        $("#add_new_record_modal").modal("hide");

        // read records again
        readRecords();
        },
        error: function() {
           //show error message
        }
    });

我真的不知道你想在这里完成什么。同时取消对表单标记的注释

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`
<form method="POST" id="image_uploader" enctype="multipart/form-data">
然后换成,

<div class="form-group">
   <label for="address">Thired step</label>
   <input type="text" id="address" placeholder="Thired step" class="form-control"/>
</div>

<div class="form-group">
    <!--<form method="POST" action="store_image.php" enctype="multipart/form-data"> -->
    <input type="file" name="imagee" id="imagee  class="form-control"/>
    <!--<input type="submit" name="submit_image" value="Upload"> -->

</div>

<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    <button type="button" class="btn btn-primary" onclick="addRecord()" enctype="multipart/form-data">Add Help</button>
</div>`
    $.ajax({
        type: "POST",
        url: "ajax/addRecord.php",
        data: formData,
        //use contentType, processData for sure.
        contentType: false,
        processData: false,
        beforeSend: function() {
            //you can add a loading icon or loading message to tell your users something is happening
        },
        success: function(msg) {
            //hide modal on success and load
// close the popup
        $("#add_new_record_modal").modal("hide");

        // read records again
        readRecords();
        },
        error: function() {
           //show error message
        }
    });

这是我的完整代码索引。。您的
标记已被注释。请不要使用mysql*函数。它不是唯一受支持的。您需要使用表单数据将图像传递到php脚本。谷歌搜索FormData。这是我的完整代码索引。phpumm。。您的
标记已被注释。请不要使用mysql*函数。它不是唯一受支持的。您需要使用表单数据将图像传递到php脚本。谷歌搜索FormData。事实上,我是在没有图像的情况下对文本进行搜索的。它可以给我一些如何添加图像的提示。这和你对图像所做的是一样的。formdata会处理这个问题。这个脚本也会将图像发布到服务器端(php)。确保保存图像的目标目录是可写的,并且具有所需的权限。你有什么错误吗?事实上,我做了一些检查,你可以检查并重新编码给我之前我评论我的洞inedx.phpvar地址=$(“#地址”).val();var imagee=$(“#imagee”).val();//$address=$_POST['address'];//$image=$\u文件['imagee']['name'];事实上,我是为没有图像的文本做这项工作的。它可以给我一些如何添加图像的提示。这和你为图像做的一样。formdata会处理这个问题。这个脚本也会将图像发布到服务器端(php)。确保保存图像的目标目录是可写的,并且具有所需的权限。你有什么错误吗?事实上,我做了一些检查,你可以检查并重新编码给我之前我评论我的洞inedx.phpvar地址=$(“#地址”).val();var imagee=$(“#imagee”).val();//$address=$_POST['address'];//$image=$\u文件['imagee']['name'];