|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-01 18:21 UTC] anton dot gudkov at flatstack dot com
Description: ------------ By default php stores sessions in files (default filepath is /var/lib/php5). If we want to store sessions, for example, in database, upload progress info doesn't appears there. Even If we change session_save_path to another directory we will get the same problem. P.S. script example you could get here: https://github.com/ihabunek/php-upload-progress and custom session handler example here: http://durak.org/sean/pubs/software/php-5.4.6/function.session-set-save- handler.html Thanks, Anton PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 18:00:01 2025 UTC |
Hi. Here is the script example which reproduces "upload progress doesn't work". Sorry for the huge script, but it couldn't be more simplier. Here is it: <?php /* if you set any writeable/readable dir to store sessions upload progress will not work. But if you comment this line, it will work. */ session_save_path('/tmp'); session_start(); $uploadName = 'test'; //upload unique name if (isset($_GET['ajax'])) { if (isset($_SESSION["upload_progress_$uploadName"])) { $progress = $_SESSION["upload_progress_$uploadName"]; $percent = round(100 * $progress['bytes_processed'] / $progress['content_length']); echo "Upload progress: $percent%<br /><pre>" . print_r($progress, 1) . '</pre>'; } else { echo 'no uploading'; } exit; } elseif (isset($_GET['frame'])) { ?> <form action="" method="POST" enctype="multipart/form-data"> <input type="hidden" name="<?=ini_get("session.upload_progress.name")?>" value="<?=$uploadName?>" /><br /> <input type="file" name="file" /><br /> <input type="submit" /> </form> <?php } else { ?> <iframe src="?frame" height="100" width="500"></iframe> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(function() { setInterval(function() { $.get('?ajax', function(data) { $('#ajax').html(data); }); }, 500); }); </script> <div id="ajax"></div> <?php }