Bayesean Blog - Desktop, Mobile and IOT Developer Blog

PHP File Downloader from a Inbox Selection

Posted on 15th Mar 2017 in Bootstrap 4, CSS


This is an update of the original blog updated from bootstrap 3 to use bootstrap 4 .The viewer has been removed and replaced with the above gif.


Project Scope

  • Must not show the download button immediately to prevent non-human downloading.
  • Must keep the user knowledgeable as to what is happening by adding a count-down timer linked to a progress bar.
  • Must flow automatically.
  • Must immediately download the file that was selected on the click of the button that became visible after completion of the progress bar.

Coding Difficulty

Medium. Good knowledge of Javascript/Ajax and PHP required would help.


Bootstrap 4 Framework –download  here.

PHP 5.6 +   download  here .

Downloader.php  -  A PHP Library (A  free to use file download library created by Jack Mason )

This is included in the included Download below.

JQuery – download from here or visit the website






This file contains the visual element of a drop down box to select the file to download.


This file contains the visual download progress bar and button to download the file.


This file is called by the download button and processes the file to download.


This holds all the mime information and allows any type of file to be downloaded.


To show and hide classes, the class “hidden” is no longer for bootstrap 4. This is replaced with class = ”d-none” to perform the same functionality.

The main action in the blog is within the interval of the JavaScript code. The Javascript countdown timer immediately starts and sets the width of the progress bar. The counter has variables to calculate the progress of the timer.

Setinterval() calls function progressbar() every  ‘100 milliseconds’  set by the var ‘stepdelay’  until completed. This is set to run for the  var ‘dcount’ times.  The var ’width’ is set to 0 because we require the progressbar to finish at 0.


The function progressbar() determines when the  image download  and button must become visible.

We use the  document.getElementById  to change the different messages in the progress bar. 

Herewith is a snippet of the main JavaScript function that controls the progress bar’s progress.

You can download the full code for the project at the end of the blog






Licence is MIT.


 Download the code from the GITHUB repository.


Download Code

John S      Commented   2 years ago Reply

Great implementation. Can use this straight in my current work

Andy      Commented   2 years ago Reply

Thumbs up

private      Commented   2 years ago Reply

Hey Do you have code for multi-file upload that works similar.

Admin      Replied    Moderator   2 years agoReply

Hi , I will work on a small blog to include multi-upload and a drag n drop option which seems to be the main trend for multi-file uploading.

Add a Comment


Recent News

Delphi Delimited String to Fields
Delphi A Professional VCL DBGrid Part Four
Delphi A Professional VCL DBGrid Part Three
Delphi A Professional VCL DBGrid Part Two
Delphi A Professional VCL DBGrid Part One
Delphi VCL Buttons in DBGrid
Two Helper Apps for Delphi LibUSB
Delphi Libusb Library Introduction


Bootstrap 4
Delphi VCL
Delphi FMX
Bootstrap 3
XE4>Delphi > XE4
Delphi < XE4


August 2019

Delphi Delimited String to Fields

June 2019

Delphi A Professional VCL DBGrid Part Four

May 2019

Delphi A Professional VCL DBGrid Part Three

April 2019

Delphi A Professional VCL DBGrid Part Two

March 2019

Delphi A Professional VCL DBGrid Part One

November 2018

Delphi VCL Buttons in DBGrid

October 2018

Two Helper Apps for Delphi LibUSB

September 2018

Delphi Libusb Library Introduction

August 2018

Delphi Object directly to a Json string in a REST Client
Delphi using Environment Variables in your App

July 2018

Delphi FMX Leaflet Plotter using OSM Maps

June 2018

C2PAS32 Convertor Application
C to Delphi Open Source Convertors Shootout
Delphi command-line programs with DOSCommand

May 2018

Delphi PDF Embedded viewer with PDF.js

March 2018

Delphi FMX - Changing TCharacter to TCharHelper
Make Your Delphi App POP using Javascript!

January 2018

Delphi FMX Dashboard using Chart.JS
Delphi FMX Form Docking

December 2017

PHP Slim REST Server & Delphi Auth Part 5

November 2017

Delphi FMX REST Client App Part 4

October 2017

Delphi VCL REST Pricing Client App Part 3

September 2017

Delphi REST VCL Client Basic Auth Part 2B

August 2017

Delphi REST Client Part 2A
PHP PDO REST Server Part 1

July 2017

PHP REST Server and Delphi Client Intro

June 2017

Delphi SQLite Encryptor-Decryptor Tool
Updating Applications Manifest using Delphi

May 2017

Create a Visual IP Address Geolocation with PHP

March 2017

PHP Downloader using Countdown timer
PHP File Downloader from a Inbox Selection

February 2017

Javascript Image-File Uploader with ThumbViewer

January 2017

Morris Charts and PHP-PDO

December 2016

CSS to create a functional Toggle Button