src/bbn/file.php
public function download()
  {
    if ( $this->file ){
      if ( !$this->size ){
        $this->get_size();
      }
      if ( $this->size && ($handle = fopen($this->file, 'r')) ){
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename="'.$this->name.'"');
        while ( !feof($handle) ){
          echo fread($handle, 65536);
        }
        fclose($handle);
      }
      else{
        die('Impossible to read the file '.$this->name);
      }
    }
    return $this;
  }
public function download()
  {
    if ( $this->file ){
      if ( !$this->size ){
        $this->get_size();
      }
      if ( $this->size && ($handle = fopen($this->file, 'r')) ){
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename="'.$this->name.'"');
        while ( !feof($handle) ){
          echo fread($handle, 65536);
        }
        fclose($handle);
      }
      else{
        die('Impossible to read the file '.$this->name);
      }
    }
    return $this;
  }
public function download ( ) { if ( $ this -> file ) { if ( ! $ this -> size ) { $ this -> get_size ( ) ; } if ( $ this -> size && ( $ handle = fopen ( $ this -> file , 'r' ) ) ) { header ( 'Content-type: application/octet-stream' ) ; header ( 'Content-Disposition: attachment; filename="' . $ this -> name . '"' ) ; while ( ! feof ( $ handle ) ) { echo fread ( $ handle , 65536 ) ; } fclose ( $ handle ) ; } else { die ( 'Impossible to read the file ' . $ this -> name ) ; } } return $ this ; }
Downloads the file. At the end of the script the user will be invited to choose the file's destination. If the file doesn't exist return an object with parameter file = null.

```php
$f = new \bbn\file('C:/Test/file.png');
$f->download();
```

@return file
Downloads the file . At the end of the script the user will be invited to choose the file s destination . If the file doesn t exist return an object with parameter file = null .