Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel download file from storage with progress bar

 <script type="text/javascript">
    $(".download").click(function(){
    window.location.href = 'file/30mb.pdf'; //set your file url which want to download
    var data = [];
    for (var i = 0; i < 100000; i++) {
    var tmp = [];
    for (var i = 0; i < 100000; i++) {
    tmp[i] = 'hue';
    }
    data[i] = tmp;
    };
    $.ajax({
    xhr: function () {
    var xhr = new window.XMLHttpRequest();
    xhr.upload.addEventListener("progress", function (evt) {
    if (evt.lengthComputable) {
    var percentComplete = evt.loaded / evt.total;
    //console.log(percentComplete);
    $('.progress').css({
    width: percentComplete * 100 + '%'
    });
    if (percentComplete === 1) {
    $('.progress').addClass('hide');
    }
    }
    }, false);
    xhr.addEventListener("progress", function (evt) {
    if (evt.lengthComputable) {
    var percentComplete = evt.loaded / evt.total;
    console.log(Math.round(percentComplete*100)+"%");
    $(".perc").text(Math.round(percentComplete*100)+"%");
    if((Math.round(percentComplete*100))==100)
    {
    $(".perc").text("download completed");
    $('.progress').removeClass('hide');
    // $(".perc").text("");
    }
    $('.progress').css({
    width: percentComplete * 100 + '%'
    });
    }
    }, false);
    return xhr;
    },
    type: 'POST',
    url: "file/30mb.pdf", //set your file url which want to download
    data: data,
    success: function (data) {}
    });
    });

    </script>
Comment

PREVIOUS NEXT
Code Example
Php :: php to python converter online free 
Php :: expression is not allowed as parameter 
Php :: Button in Laravel Datatable not rendering 
Php :: waht is middleware in laravel 
Php :: yoast seo alternative for laravel 
Php :: General errorstring fetchAll() php 
Php :: laravel creating_table_name 
Php :: object initialization 
Php :: stupidity 
Php :: When I try to run my code in chrome, i see the code that I have made in phpstorm and not the function that it has to do 
Php :: how to check my server use cgi, fcgi or fpm. 
Php :: afosto/yaac error parsing certificate request 
Php :: radio checked according to previous data in latravel 
Php :: laravel change value to intger 
Php :: how to react on a html button click in php 
Php :: phphtml 
Php :: get product by author id 
Php :: same name selection in phpstorm mac 
Php :: Donut chart in PHP 
Php :: how to restrict user to some pages using php 
Php :: gan_sql 
Php :: Reference — What does this symbol mean in PHP? 
Php :: codeigniter 4 base_url 
Php :: prevent undefined offset php 
Php :: Route::whereIn 
Php :: Select All Data From MySql Database Table PHP Function 
Php :: File: C:xampphtdocsmarvellogistikapplicationlibrariesProfiler.php Line: 386 Function: sendDataInHeaders 
Php :: larvel still laod the local file location on production 
Php :: findmany laravel 
Php :: Display a variable containing html in laravel 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =