Ads

Wednesday, October 14, 2015

Download a file with High Speed - PHP Tutorials

Today I'm going to share a PHP Tutorial.You can download any file with high speed (upto 13MB/sec) even if your internet connect is slow or very slow.
Just create a php file on your server and add this code in your file.

<?php

/**
 * @Project       School Management System
 * @Company       MASGE INC.
 * @Author        Muhammad Athar
 * @Email         masge.info@gmail.com
 * @Copyright     2015
 */


if($_REQUEST['action']=='download' && !empty($_REQUEST['file']))
{
    $filess = explode('/',$_REQUEST['file']);
    foreach($filess as $filee)
    {
        $d = $filee;
    }
   header('Content-Type: application/octet-stream');
   header('Content-Length: ' . filesize($_REQUEST['file']));
   header('Content-Disposition: filename='.$d);
   flush();
    $file = fopen($_REQUEST['file'], "r");

    while (!feof($file)) {

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

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

        // sleep one second
        sleep(1);
    }

    // close file stream
    fclose($file);
   
}


?>

Proof



No comments:

Post a Comment