Login   Register  
PHP Classes
elePHPant
Icontem

File: display.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of M.G.Ranga Pathmasiri  >  File Uploading Web interface  >  display.php  >  Download  
File: display.php
Role: Example script
Content type: text/plain
Description: This is the execute file
Class: File Uploading Web interface
Simple file uploading form handling
Author: By
Last change:
Date: 10 years ago
Size: 3,318 bytes
 

Contents

Class file image Download
<?php
error_reporting
(E_ALL);
session_start();
require_once(
"../html/define.inc.php"); 
 
if (isset(
$_POST['remove']) && ($_POST['remove']) && (isset($_POST['item'])))
{
   
$name $_POST["item"] ;
   if (
is_array($name))
   {
    if (
count($_SESSION['fileinfo']))
     {
     foreach (
$name as $ikey=>$ivalue)
       {
           unset(
$_SESSION['fileinfo'][$ivalue]);
           
reset($_SESSION['fileinfo']);     
       }
     }  
     
   }

 
 

if (isset(
$_POST['Ok']) && ($_POST['Ok']))
{
  if(isset(
$_FILES['file']) && ($_FILES['file']['name']))
     {
       require(
"../html/session.inc.php");
       foreach(
$_SESSION['fileinfo'] as $key=>$value)
          {
            
$up_file_tmpname $value['tmp_name'];
            
$up_file_name    $value['file_name'] ;
          }
          if ((
$up_file_tmpname) && ($up_file_name))
          {
          require(
"../html/fileupload.class.php");
          
$file = new File_upload($up_file_name,  $up_file_tmpname);
          
$file-> init() ; 
          }    
      }
     else
     {
       
$error       true;
       
$file_error  =  $error_array['fileerror']; 
      
     
     }
}
if (
session_is_registered('fileinfo'))
{
   
  
  
ob_start();
  if (
count($_SESSION['fileinfo']))
  {
  foreach (
$_SESSION['fileinfo'] as $key=>$value)
   {
       
     
      for (
$i $i <= $value["file_count"] ; $i++)
       {
        
$size   $value["file_size"] / 1000 ;
        
$total += $size 1024;
        
$html $html .  "<tr bgcolor='#FFFFFF'> 
                          <td width='80' nowrap> 
$value[file_name]</td>
                          <td nowrap><div align='right'>
$size KB</div></td>
                          <td nowrap><div align='right'> 
                          <input name='item[]' type='checkbox' id='item[]' value='
$value[file_name]'>
                          </div></td>
                          </tr>" 
;
      
      }
   
   }
   }
if ((
$html) && ($total))
{
   
$html $html;
   
$total_value round($total4) ; 
   
$pvalue $total_value floatval(CAPACITY) * 100;
   if (
$pvalue >= 98)   $inough true
}   
   
ob_end_flush();
   
   
}
if (isset(
$_POST['Submit']) && ($_POST['Submit']))

  
  
    if ((
session_is_registered('fileinfo')) && (count($_SESSION['fileinfo'])))
       {
       
clearstatcache(); 
       
$handle opendir(DIR_NAME DEFAULT_USER_NAME) ;
       
ob_start();
     
       while (
false !== ($file readdir($handle))) {
           if(
$file == "."){
                 
//skip
                 
}
                 elseif(
$file == ".."){
                 
//skip
                 
}
                 else{
                     
$file_count++;
                     if (!isset(
$_SESSION['fileinfo'][$file]))
                      {
                            
$temp =DIR_NAME DEFAULT_USER_NAME "/" $file;
                            if (
is_file($temp)) unlink($temp);  
                       }  
                       }
            
           
           
                 }
                 
ob_end_flush();
                  
          
           
       }
   
    else if((
session_is_registered('fileinfo')) &&  (!$file_count))
    {
       
$dir DIR_NAME DEFAULT_USER_NAME ;
       if (
is_dir($dir)) rmdir($dir);
       
session_unregister('fileinfo');
       
$error       true;
       
$file_error  =  $error_array['notfile']; 
    
    }
    else
    
     {
       
$error       true;
       
$file_error  =  $error_array['notfile']; 
     }
   
 

}
require_once(
"../html/display.inc.php");

?>