WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A PHP function to force a browser to download a given file in the web server. It's also possible to set the max download speed via a second argument.
Categories : PHP, Filesystem Click here to Update Your Picture
Alix Axel
Date : Nov 23rd 2008
Grade : 5 of 5 (graded 1 times)
Viewed : 2978
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alix Axel
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

<?php

function Download($path, $speed = null)
{
    if (
is_file($path) === true)
    {
       
set_time_limit(0);

        while (
ob_get_level() > 0)
        {
           
ob_end_clean();
        }

       
$speed = (is_null($speed) === true) ? filesize($path) : intval($speed) * 1024;

       
header('Expires: 0');
       
header('Pragma: public');
       
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
       
header('Content-Type: application/octet-stream');
       
header('Content-Length: ' . filesize($path));
       
header('Content-Disposition: attachment; filename="' . basename($path) . '"');
       
header('Content-Transfer-Encoding: binary');

        for (
$i = 0; $i <= filesize($path); $i = $i + $speed)
        {
            echo
file_get_contents($path, false, null, $i, $speed);

           
flush();
           
sleep(1);
        }

        exit();
    }

    return
false;
}

?>



Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
Execute a command to a string
Categories : PHP, Program Execution, Filesystem
Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression
Single-file PHP news system with automatic folder structure creation
Categories : PHP, Filesystem, Arrays
A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database.
Categories : PHP, Filesystem, FTP, Date Time, Databases
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Read DPI value from image with PHP
Categories : PHP, Graphics, Filesystem
directory, opendir, listfiles, files in a directory, get directory
Categories : PHP, Filesystem
getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory, filtered by regular expression and either sorted or randomized. Good for random pictures and graphics.
Categories : PHP, Filesystem, Directories
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays
Listing the 10 most recently updated files in a given dir by using last- modified variable and printing to html with link to the file
Categories : PHP, Directories, Filesystem
The toll booth
Categories : PHP, Java Script, Filesystem
Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS
Categories : PHP, Databases, PostgreSQL, Filesystem
Opening and formatting text files into HTML on the fly- or HTML from templates.
Categories : PHP, HTML and PHP, Filesystem
Creating a Language File
Categories : PHP, Beginner Guides, Filesystem