PHP session.upload_progress没有返回任何值

时间:2014-04-11 13:16:28

标签: javascript php session

我想利用PHP 5.4中引入的upload_progress会话。但我无法得到任何结果。

这是我的表格:

<form enctype="formdata/multipart">
<input type="hidden" id='prog' value='test' name="<?php echo ini_get("session.upload_progress.name"); ?>">
    <label>Upload Your Files</label><br />
    <input name="file" type="file" id="file"><br />
    <input name="send" value="Upload!" id="uploadButton" type="submit" />

    <br />

</form>

这是我的Javascript:

sub.addEventListener("click", function(event){

            event.preventDefault();
            event.stopPropagation();

            formData.append("file", file.files[0]);

            var http = new XMLHttpRequest();
            http.open("POST", "upload.php");

            http.setRequestHeader("Cache-Control", "no-cache");

            http.addEventListener("load", function(){
                console.log("Finished.");
            }, false);


            var myprogfield = document.getElementById("prog");
            formData.append(myprogfield.getAttribute("name"), myprogfield.value);

            http.send(formData);



            setInterval(function(){
                var http = new XMLHttpRequest();
                http.open("GET", "progress.php");               
                http.send(null);
            }, 500);


        }, false);

如您所见,我使用以下命令向progress.php发送请求以从中获取结果。

    setInterval(function(){
        var http = new XMLHttpRequest();
        http.open("GET", "progress.php");               
        http.send(null);
    }, 500);

这是progress.php,我echo()每次$_SESSION获取$ _SESSION的所有值,但每次都将它发送为null。

<?php
session_start();

var_dump($_SESSION);

0 个答案:

没有答案