vendredi 23 octobre 2015

Laravel 5.1 using session.upload_progress

I want to build a progess bar with the status of my php script. I have read that it could be done with using session.upload_progress.

I'm using laravel Homestead and in the php.ini all requerements are active.

This is my html

{!! Form::open(['route' => 'gebruikers_upload', 'class' => 'form-horizontal import', 'enctype' => 'multipart/form-data', 'target' => 'hidden_iframe']) !!}
                            <input type="hidden" value="myForm" name="{{ini_get("session.upload_progress.name")}}">
                            <input type="file" name="file" id="the-file"/>
                            <button class="btn btn-sm btn-info btn_import" type="submit">Importeer</button>
                            <button class="btn btn-sm btn-danger" type="button">Cancel</button>
                        {!! Form::close() !!}
                        {{--End Form--}}

                        <iframe id="hidden_iframe" name="hidden_iframe" src="about:blank"></iframe>

                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="25"
                                    aria-valuemin="0" aria-valuemax="100" style="width: 45%">
                                <span class="">45% Complete</span>
                            </div>
                        </div>

When submiting te route is:

Route::get('dashboard/gebruikers/upload_status', 'UserController@uploadStatus');

And in the controller UserController in method uploadStatus i have this

public function uploadStatus(Request $request)
{
    session_start();

    echo '<pre>';
        print_r($_SESSION);
    echo '</pre>';
}

But it always shows an empty array. And when i use this code

    $data = $request->session()->all();

    echo '<pre>';
    print_r($data);
    echo '</pre>';

It returns this

Array
(
    [_token] => jFkleI9kIZJiZP3pEARx0hDrHtsynPmuGkse97nT
    [_previous] => Array
        (
            [url] => http://ift.tt/1KtE1ox
        )

    [flash] => Array
        (
            [old] => Array
                (
                )

            [new] => Array
                (
                )

        )

    [login_82e5d2c56bdd0811318f0cf078b78bfc] => 1
)

But there is no info about progress updating.

How could i use this with laravel 5.1



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire