Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:20:31+00:00 2026-06-18T03:20:31+00:00

I’m trying to get the Session Upload Progress feature ( http://php.net/manual/en/session.upload-progress.php ) to work

  • 0

I’m trying to get the Session Upload Progress feature ( http://php.net/manual/en/session.upload-progress.php ) to work in Kohana. I have managed to get it working locally without Kohana using the following code:

<?php
    session_start();
    if (isset($_GET['progress']))
    {
        // does key exist
        $key = ini_get("session.upload_progress.prefix") . 'demo';
        if ( !isset( $_SESSION[$key] ) ) exit( "uploading..." );

        // workout percentage
        $upload_progress = $_SESSION[$key];
        $progress = round( ($upload_progress['bytes_processed'] / $upload_progress['content_length']) * 100, 2 );

        exit( "Upload progress: $progress%" );
    }
?>
<!doctype html>
<head>
</head>
<body>
    <section>
        <h1>Upload Form</h1>
        <form action="" method="POST" enctype="multipart/form-data" target="upload-frame">
            <input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="<?php //echo $uid; ?>demo">
            <p>
                <label>File:</label>
                <input type="file" name="file" required="required">
            </p>
            <p><input type="submit" name="submit" value="Upload"></p>
        </form>

        <iframe id="upload-frame" name="upload-frame" width="1280" height="600"></iframe>

        <div id="file_upload_progress"></div>
    </section>

    <script src="jquery-1.7.1.min.js"></script>
    <script>
        $(document).ready(function() {

            var uploading = false;
            $('form').submit(function() {

                uploading = true;
                $('#upload-frame').one('load', function(){
                    uploading = false;
                });

                function update_file_upload_progress() {
                    $.get("?progress", function(data) {
                        $("#file_upload_progress").html(data);
                        if (uploading) {
                            setTimeout( update_file_upload_progress, 500 );
                        }
                    })
                    .error(function(jqXHR, error) { 
                        alert(error); 
                    });
                }

                // first call
                update_file_upload_progress();
            });
      });
    </script>
</body>
</html>

However when I use this code in Kohana (separating the PHP into a controller of course) the $_SESSION variable does not get created for tracking the progress of the upload.

I believe this is something to do with how sessions in Kohana work. I cannot have session_start() at the start of the script as it conflicts with the Kohana session that’s already running. If I dump out the $_SESSION or Session::instance() contents the variable that should be added by the PHP Upload Progress functionality isn’t there.

So how do I get the session variable to work with Kohana?

UPDATE

I have since created a clean install of Kohana to help narrow down on this issue. I have found that by not instantiating the Session class in Kohana that I can use the code above and it works fine.

However when the Session class is instantiated which it needs to be for my web application it stops working and the $_SESSION variable containing upload progress is no longer created. This leads me to believe that the issue lies somewhere within how Kohana manages session information. I tried turning off the encryption with config settings but that didn’t make a difference.

I’m using native session.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:20:33+00:00Added an answer on June 18, 2026 at 3:20 am

    Session cookie name has to be exactly the same as the one set in php config (session.name), e.g.:

    return array(
        'native' => array(
            'encrypted' => FALSE,
            'name'      => ini_get('session.name'),
        ),
    );
    

    If you don’t want to use PHP’s default session cookie name you will not get around this by setting the value during runtime, i.e. this won’t work:

    ini_set('session.name', 'my_kohana_session_name');
    

    You will get around this by setting the value in your .htaccess file:

    php_flag session.name "my_kohana_session_name"
    

    This way you can keep the php.ini untouched but you can keep your custom cookie name for your Kohana application.

    My tests proved that session encryption does not affect the upload progress information when using native session driver. That surely because the encryption is not used when using native driver regaldess the setting. 😉

    PS. One thing I would also suggest – make sure that the ajax request is not cached. Had quite a few cases when it was cached and not showing fresh responses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.