Labels

php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Monday, May 28, 2018

Download file with speed limit using PHP

Here we are explaining about how to limit speed for the file download operation.


<?php
// File form server
$local_file = 'user.php';

// filename that the user gets as default
$download_file = 'myFile.php';

// set the download rate limit (=> 10 kb/s)
$download_rate = 10;

if(file_exists($local_file) && is_file($local_file)) {

    // send headers
    header('Cache-control: private');
    header('Content-Type: application/octet-stream');
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: filename='.$download_file);

    // flush content
    flush();

    // open file stream
    $file = fopen($local_file, "r");

    while (!feof($file)) {

        // send the current file part to the browser
        print fread($file, round($download_rate * 10));

        // flush the content to the browser
        flush();

        // sleep one second
        sleep(1);
    }

    // close file stream
    fclose($file);
}
else {
    die('Error: The file '.$local_file.' does not exist!');
}
?>

For more:

Unknown Features
Beautiful Designs
Security Features

19 comments:

  1. Thank for your writting! I have read through some similar topics! However, your post has given me a very special impression, unlike other posts. I hope you continue to have valuable articles like this or more to share with everyone!
    link access to register here:
    duck life 3
    vex 3
    fnaf

    ReplyDelete
  2. This article is very nice.
    If you are facing problems How To Refund In QuickBooks, then you can directly contact QuickBooks Online Support +1-877-249-9444.

    ReplyDelete
  3. Buy Malegra 100mg Online From Trusted online pharmacy Medypharma. Malegra 100mg The drug contains sildenafil citrate. Buy Generic Sildenafil citrate at Lowest Price Online ✅. malegra 100 for sale, malegra 100 pro review. cheap Malegra 100 from your reliable pharmacy.

    ReplyDelete
  4. Buy Malegra 200mg Online belongs to containt of Sildenafil Citrate . Know More about Malegra 200 mg price , uses , How to use , How to take . cheap generic Viagra from this online pharmacy Medypharma, get great discounts and home delivery. Order Now! buy malegra online , cheap malegra 100

    ReplyDelete
  5. Buy Super Kamagra Online is a combination medication consisting of Sildenafil Citrate 100 mg and Dapoxetine Hydrochloride 60 mg. Sildenafil is used to treat erectile dysfunction. Know about super kamagra uses , Price , How to take , Side Effect , How to use .cheap kamagra from Online Trusted Pharmacy Medypharma.

    ReplyDelete
  6. Interesting post! I really amazed to read the great information. You have shared best quality stuff in the content of the post. Thank you so much for such an awesome blog post!

    ReplyDelete
  7. Buy Vidalista Professional Online is an FDA-approved medicine used to treat erectile dysfunction problems in men.Know about vidalista uses , Price , How to take , Side Effect , How to use. vidalista professional 20 review from Trusted Online Pharmacy Medypharma.

    ReplyDelete
  8. Buy Vidalista Professional Online is an FDA-approved medicine used to treat erectile dysfunction problems in men.Know about vidalista uses , Price , How to take , Side Effect , How to use. vidalista professional 20 review from Trusted Online Pharmacy Medypharma.

    ReplyDelete
  9. BuyKamagra Gold 100mg Online is used for Enlarged prostate gland in male, Increased blood pressure in lungs and other conditions. Know about the uses, side effects, price, composition, substitutes, How it works, Lowest Price Online. Kamagra Gold 100mg Online buy with lowest Price Ever Online Pharmacy. Kamagra Gold 100mg Reviews.

    ReplyDelete

More Posts

FOLLOW