Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP上传进度_Php_File Upload_Progress - Fatal编程技术网

PHP上传进度

PHP上传进度,php,file-upload,progress,Php,File Upload,Progress,经过3天的测试、研究和失败,我需要你的帮助 我有这个HTML表单 <form action="upload.php" method="POST" enctype="multipart/form-data" target="upload_target" > <input type="hidden" name='<?php echo ini_get("session.upload_progress.name"); ?>"' value="myUploadProg

经过3天的测试、研究和失败,我需要你的帮助

我有这个HTML表单

<form action="upload.php" method="POST" enctype="multipart/form-data" target="upload_target" >
    <input type="hidden" name='<?php echo ini_get("session.upload_progress.name"); ?>"' value="myUploadProgress">
    <input type="file" name="myfile" id="file1" style="display:none">
    <button id="browse-button">Browse</button>
    <input id="update-button" class="disabled" type="submit" name="submitBtn" value="Update" />
</form>
我将php分为两个步骤:

upload.php-发布表单

<?php
    session_start();

    getcwd().DIRECTORY_SEPARATOR;

    chdir('/tmp');

    $destination_path = getcwd();

    $result = 0;

    $target_path = $destination_path . '/' .basename( $_FILES['myfile']['name']);

    if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
        $result = 1;
    }

    sleep(1);
?>
upload_status.php-由ajax请求以1000毫秒的间隔触发

<?php

    print_r($_SESSION);

?>
出于某种原因,我一直将$\u SESSION设置为空,并希望将$\u SESSION[upload\u progress\u myUploadProgress]或其他内容设置为我当前上传的变量数组

我已经检查过并且已经存在于php.ini中的内容

文件上传:打开 贴纸最大尺寸:2G 上载\u最大\u文件大小:2G 输出缓冲:关闭 session.upload_progress.cleanup:打开 session.upload\u progress.enabled:打开 session.upload_progress.freq:1% session.upload\u progress.min\u频率:1 session.upload\u progress.name:PHP\u session\u upload\u progress session.upload\u progress.prefix:上传\u进度_
据我所知,在上传文件时,我应该在会话中将上传进度作为密钥。我不认为我需要为$_SESSIONAh做任何设置,我明白了,你在你提供的链接上读过下面的评论了吗:当你的web服务器通过FastCGI等运行PHP时,必须禁用web服务器的请求缓冲或此功能不起作用。你使用的是什么PHP版本?它当前处于关闭状态,抱歉,我在问题中没有提到这一点。这可能会有所帮助:尝试添加会话\u start;在打印前的upload_status.php中