小编Pn1*_*n12的帖子

当php脚本通过ajax运行时显示进度条

我有一个表单,通过ajax向服务器提交值.

<form>
<input id="titlee" name="titlee">
<input type="file" name="fileToUpload" id="fileToUpload">
<button  type="submit" value="submit" id="submit" name="submit">Start</button>
<div class="progress"></div>
</form>
Run Code Online (Sandbox Code Playgroud)

脚本

<script type="text/javascript">
$(function() 
    {
        $("#submit").click(function() 
            {
                var titlee = $("#titlee").val();
                var fileToUpload= $("#fileToUpload").val();

                var dataString = 'titlee='+ titlee + '&fileToUpload=' + fileToUpload;

                $.ajax(
                    {
                        type: "POST",
                        url: "c_insert_test.php",
                        data: dataString,
                        success: function()
                    });

                return false;
            });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

c_insert_test.php

   <?php
    $titlee = $_POST['titlee'];
    $target_dir = "reqdoc/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

    $new_filename = $target_dir . uniqid() …
Run Code Online (Sandbox Code Playgroud)

javascript php mysql ajax jquery

6
推荐指数
0
解决办法
7396
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1

mysql ×1

php ×1