• <bdo id='cHA6D'></bdo><ul id='cHA6D'></ul>

      <legend id='cHA6D'><style id='cHA6D'><dir id='cHA6D'><q id='cHA6D'></q></dir></style></legend>
    1. <small id='cHA6D'></small><noframes id='cHA6D'>

    2. <tfoot id='cHA6D'></tfoot>
        <i id='cHA6D'><tr id='cHA6D'><dt id='cHA6D'><q id='cHA6D'><span id='cHA6D'><b id='cHA6D'><form id='cHA6D'><ins id='cHA6D'></ins><ul id='cHA6D'></ul><sub id='cHA6D'></sub></form><legend id='cHA6D'></legend><bdo id='cHA6D'><pre id='cHA6D'><center id='cHA6D'></center></pre></bdo></b><th id='cHA6D'></th></span></q></dt></tr></i><div id='cHA6D'><tfoot id='cHA6D'></tfoot><dl id='cHA6D'><fieldset id='cHA6D'></fieldset></dl></div>
      1. PhP 5.4 中的 PhP 上传进度不起作用.会话变量未设置

        时间:2023-05-21

            <bdo id='fpG9m'></bdo><ul id='fpG9m'></ul>
            <legend id='fpG9m'><style id='fpG9m'><dir id='fpG9m'><q id='fpG9m'></q></dir></style></legend>
                <tbody id='fpG9m'></tbody>

                <tfoot id='fpG9m'></tfoot>

                  <small id='fpG9m'></small><noframes id='fpG9m'>

                1. <i id='fpG9m'><tr id='fpG9m'><dt id='fpG9m'><q id='fpG9m'><span id='fpG9m'><b id='fpG9m'><form id='fpG9m'><ins id='fpG9m'></ins><ul id='fpG9m'></ul><sub id='fpG9m'></sub></form><legend id='fpG9m'></legend><bdo id='fpG9m'><pre id='fpG9m'><center id='fpG9m'></center></pre></bdo></b><th id='fpG9m'></th></span></q></dt></tr></i><div id='fpG9m'><tfoot id='fpG9m'></tfoot><dl id='fpG9m'><fieldset id='fpG9m'></fieldset></dl></div>
                2. 本文介绍了PhP 5.4 中的 PhP 上传进度不起作用.会话变量未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我一开始就遇到了 PhP 文件上传进度监视器的问题.

                  I have a problem with PhP File Upload progress monitor at the very start.

                  首先,这里是相关的 PhP.ini 设置(指令、本地值和主值):

                  First, here are the relevant PhP.ini settings (Directive, Local Value and Master Value):

                       session.upload_progress.cleanup    On  On
                       session.upload_progress.enabled    On  On
                       session.upload_progress.freq   1%  1%
                       session.upload_progress.min_freq   1   1
                       session.upload_progress.name   PHP_SESSION_UPLOAD_PROGRESS  PHP_SESSION_UPLOAD_PROGRESS
                       session.upload_progress.prefix upload_progress_    upload_progress_
                  

                  这是表格(简化版):

                       <form id="fileupload" style="position:relative;" target="iframe_fileupload" action="http://www.athiyoga.org/testupload.php" method="POST" enctype="multipart/form-data">
                              <input type="hidden" name="<?echo ini_get("session.upload_progress.name");?>" value="first"/>
                               <input type="file" name="file_1">
                              <button type="submit" >Start Submit</button>
                        </form>
                  

                  我有 JQUERY Ajax 代码,在同一个 PhP 文件中(当然,作为一个 JS 脚本),如:

                  I have JQUERY Ajax code, in the same PhP file (of course, as a JS script), as in:

                      $('#fileupload').submit(function(event){
                  
                      //UPDATED THIS PART after reading: http://stackoverflow.com/questions/19336610/delay-in-populating-session-upload-progress-data
                      //POSTING the magic variable PHP_SESSION_UPLOAD_PROGRESS during status inquiry too
                  
                         var params = {PHP_SESSION_UPLOAD_PROGRESS:"first", some_var:20 };
                         var data_params = jQuery.param( params );
                         setTimeout(function(){
                                upload_promise = $.ajax({
                                  url: 'upload_status.php', 
                                  data: data_params,
                                  dataType: 'html',
                                  type    : 'POST',
                                  cache   : false 
                               });
                               $.when(upload_promise).done(function(status_response){
                                     $('#response_status').html(status_response);
                               });
                          },5000);
                        ...
                        ...
                  

                  upload_status.php 只是回应 $_SESSION 数组.我还在 form-php 中设置了一个测试会话变量,以确保 AJAX(通过 upload_status.php)选择该会话变量.确实如此.但不是 $_SESSION 数组中上传状态的标志(无变量/索引)!文件被上传.我确保文件足够大,以便 5000 毫秒足以报告一些中间状态.

                  The upload_status.php simply echoes the $_SESSION array. I also set a test session variable in the form-php to make sure that the AJAX (thru upload_status.php) picks that session variable. It does. But not a sign (no variable/index) of the upload status in the $_SESSION array! The files get uploaded. I made sure that the files are big enough so that the 5000ms is sufficient to report some intermediate status.

                  我之前从未实现过 PhP 文件上传进度条,所以我想知道我是否遗漏了什么.一旦我在上传中获得一个状态点,我就可以完成其余的工作.

                  I have never implemented PhP file upload progress bar before so I wonder if I am missing something. Once I get one status-point in the upload, I will be able to do the rest.

                  谢谢

                  推荐答案

                  可能存在一些问题,我已经列出了其中的几个.

                  There could be some issues, I have listed down few of them.

                  • 必须禁用 Web 服务器的请求缓冲才能使其正常工作,否则 PHP 可能仅在完全上传后才能看到文件上传.
                  • 当您的网络服务器通过 FastCGI 运行 PHP 时,此功能不起作用.
                  • 不要忘记,必须在生成表单之前初始化会话,否则您将无法在会话中获得任何信息.
                  • 它不适用于 PHP 5.3 或更早版本.
                  • 请注意,如果您运行该代码并打印出 $_SESSSION[$key] 的内容,您会得到一个空数组,因为 session.upload_progress.cleanup 默认是打开的,并且它会在所有 POST 后立即清除进度信息数据已读取.将其设置为 Off 或 0 以查看 $_SESSION[$key] 的内容.

                  这可以帮助您跟踪进度条http://pecl.php.net/package/uploadprogress

                  This can help you to track your progress bar http://pecl.php.net/package/uploadprogress

                  我希望这能帮助您找出问题所在.

                  I hope this will help you to dig out the problem.

                  这篇关于PhP 5.4 中的 PhP 上传进度不起作用.会话变量未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP 上传大小及其对帖子大小和内存限制的影响 下一篇:使用jquery上传图片

                  相关文章

                  最新文章

                  <small id='yNfwK'></small><noframes id='yNfwK'>

                  <tfoot id='yNfwK'></tfoot>

                  1. <legend id='yNfwK'><style id='yNfwK'><dir id='yNfwK'><q id='yNfwK'></q></dir></style></legend>

                        <bdo id='yNfwK'></bdo><ul id='yNfwK'></ul>
                      <i id='yNfwK'><tr id='yNfwK'><dt id='yNfwK'><q id='yNfwK'><span id='yNfwK'><b id='yNfwK'><form id='yNfwK'><ins id='yNfwK'></ins><ul id='yNfwK'></ul><sub id='yNfwK'></sub></form><legend id='yNfwK'></legend><bdo id='yNfwK'><pre id='yNfwK'><center id='yNfwK'></center></pre></bdo></b><th id='yNfwK'></th></span></q></dt></tr></i><div id='yNfwK'><tfoot id='yNfwK'></tfoot><dl id='yNfwK'><fieldset id='yNfwK'></fieldset></dl></div>