PHP Classes

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Pierre-Henry Soria  >  PHP 5.4 Session Upload Progress Bar  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP 5.4 Session Upload Progress Bar
Track the progress of file uploads using sessions
Author: By
Last change:
Date: 2 years ago
Size: 2,857 bytes


Class file image Download
 * @category PHP5.4 Progress Bar
 * @author Pierre-Henry Soria <>
 * @copyright (c) 2012, Pierre-Henry Soria. All Rights Reserved.
 * @license CC-BY License -
 * @version 1.0.0

 * Check the version of PHP
if (version_compare(phpversion(), '5.4.0', '<'))
'ERROR: Your PHP version is ' . phpversion() . ' but this script requires PHP 5.4.0 or higher.');

 * Check if "session upload progress" is enabled
if (!intval(ini_get('session.upload_progress.enabled')))
'session.upload_progress.enabled is not enabled, please activate it in your PHP config file to use this script.');

<!DOCTYPE html>
<html lang="en-US">
      <meta charset="utf-8" />
      <title>PHP 5.4 Session Upload Progress Bar Demo</title>
      <meta name="description" content="PHP 5.4 Session Upload Progress Bar" />
      <meta name="keywords" content="PHP, session, upload, progress bar" />
      <meta name="author" content="Pierre-Henry Soria" />
      <link rel="stylesheet" href="./static/css/common.css" />

  <div id="container">

    <h1>Example for Progress Bar with PHP 5.4 and jQuery</h1>

  <!-- Debug Mod --> <!-- <form action="upload.php?show_transfer=on" method="post" id="upload_form" enctype="multipart/form-data" target="result_frame"> -->
  <form action="upload.php" method="post" id="upload_form" enctype="multipart/form-data" target="result_frame">
          <legend>Upload Images</legend>
          <input type="hidden" name="<?php echo ini_get('');?>" value="<?php Upload::UPLOAD_PROGRESS_PREFIX ?>" />
          <label for="file">Images: <input type="file" name="files[]" id="file" multiple="multiple" accept="image/*" required="required" />
          <small><em>You can select multiple files at once by clicking multiple files while holding down the "CTRL" key.</em></small></label>
          <button type="submit" id="upload">Upload!</button>
          <button type="reset" id="cancel">Cancel Upload</button>

      <!-- Progress bar here -->
      <div id="upload_progress" class="hidden center progress">
          <div class="bar"></div>


  <iframe id="result_frame" name="result_frame" src="about:blank"></iframe>

    <p>By <strong><a href="">pH7</a></strong> &copy; 2012.</p>

  <script src=""></script>
  <script src="./static/js/ProgressBar.class.js"></script>
  $('#upload').click(function() {
    (new UploadBar).upload();
  $('#cancel').click(function() {
    (new UploadBar).cancel();