Ads

Showing posts with label serve a file with high speed. Show all posts
Showing posts with label serve a file with high speed. Show all posts

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



Saturday, August 1, 2015

Serve a file using php with high speed.

Learn How to serve a file using php with high speed?
Create a page download.php
 

  <?php
/**
  * @Project PKSkiET
  * @Company SkiET 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);
                 } ?>

Now open http://server/download.php?action=download&file=[your file located on your server]