Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mhyk Duterte  >  Hybrid Upload Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage sample
Class: Hybrid Upload Class
Validate and process files uploaded via Web forms
Author: By
Last change: Example file updated
Date: 2005-06-25 18:38
Size: 1,095 bytes
 

Contents

Class file image Download
<?php

/********************************************

    Example Usage: Multiple file uploading

*********************************************/

error_reporting(E_ALL);

if (! isset(
$_POST['Submit'])) {

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
<input type="file" name="file1" /><br />
<input type="file" name="file2" /><br />
<input type="file" name="file3" /><br />
<input type="submit" name="Submit" />
</form>
<?php

} else {
    
// Include the class file
    
require_once('Upload.class.php');
    for (
$x 1$x <= 3$x++) {
        
$upload = new Upload('file'.$x,'C:/');
        
// Max file size
        
$upload->setMaxFileSize(10,UPLOAD_SIZE_MBYTES);
        
// Array of valid extensions
        // Use * to allow all files
        
$upload->setTypes(array('*')); 
        
// Upload the current file
        
$process $upload->process();
    
        if (! 
$process) {
            echo 
$upload->getMessage().'<br />';
        } else {
            echo 
'File '.$x.' Uploaded...<br />';
            echo 
'Size: '$upload->getFileSize().'MB<br /><br />';
        }
    }
}

?>