Login   Register  
PHP Classes
elePHPant
Icontem

File: usageFileUpload

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Qazi Umar Aadil Shah  >  Umar File Upload  >  usageFileUpload  >  Download  
File: usageFileUpload
Role: Auxiliary script
Content type: text/plain
Description: usageFileUpload
Class: Umar File Upload
Check and process uploaded files
Author: By
Last change:
Date: 4 years ago
Size: 2,692 bytes
 

Contents

Class file image Download
<?php




    
/******************************************
    Function name : uploadUserFile
    Return type : boolean
    Date created : 6th April 2010
    Date last modified : 6th April 2010
    Author : Qazi Umar
    Last modified by : Qazi Umar
    Comments : This function Will Upload the file.
    User instruction : $objPage->uploadUserFile();
    ******************************************/
    
function uploadUserFile()
    {
        if(isset(
$_FILES['frmUploadFile']) && $_FILES['frmUploadFile']['name'] != '')
        {
            
// ini changes
            
ini_set("max_execution_time",0);
            
ini_set('post_max_size','200M');
            
ini_set("upload_max_filesize""180M");
            
ini_set("max_input_time""180");

            
// Upload class
            
            
$objUpload = new uploadFiles();
            

            
$objUpload->setDirectory(UPLOAD_PATH);
            
$objUpload->setFileTypes(FILE_UPLOAD_TYPES);
            
$objUpload->setMaxSize(MAX_FILE_SIZE);

            
$fileName generateMediaFileName();
            
$uploadedFileName $objUpload->uploadFile('frmUploadFile'$fileName);

            if(
$uploadedFileName != false)
            {
                
$varFileUploadName = ($uploadedFileName) ? $uploadedFileName '';
                return 
true;
            }
            else
            {
                
$varErrorMessage 'Error in Upload.';
                return 
false;
            }
        }
        else
            return 
true;
    }
    
    
    
    
/******************************************
    Function name : generateMediaFileName
    Return type : string
    Date created : 01 February 2010
    Date last modified : 01 February 2010
    Author : Qazi Umar
    Last modified by : Qazi Umar
    Comments : This function returns  the options of drop down menu
    User instruction : $id = $obj->generateMediaFileName()
    ******************************************/
    
    
function generateMediaFileName($argFileExt='')
    {
        
$strAlphaNumeric getRandomAlphaNumeric(8).'-'.getRandomAlphaNumeric(4).'-'.getRandomAlphaNumeric(12).$argFileExt;
        return 
$strAlphaNumeric;    
    }
    
    
/******************************************
    Function name : getRandomAlphaNumeric
    Return type : string
    Date created : 01 February 2010
    Date last modified : 01 February 2010
    Author : Qazi Umar
    Last modified by : Qazi Umar
    Comments : This function returns  the options of drop down menu
    User instruction : $id = $obj->getRandomAlphaNumeric()
    ******************************************/
    
    
function getRandomAlphaNumeric($argIntpLength 16)
    {
        
$arrAlphaNumeric = array();
        
$arrAlpha range('A','Z');
        
$arrNumeric range(0,9);
        
        
$arrAlphaNumeric array_merge($arrAlphaNumeric$arrAlpha$arrNumeric);
        
        
mt_srand((double)microtime() * 1234567);
        
shuffle($arrAlphaNumeric);

        
$strAlphaNumeric '';
        for(
$x=0$x<$argIntpLength$x++)
        {
            
$strAlphaNumeric .= $arrAlphaNumeric[mt_rand(0, (sizeof($arrAlphaNumeric)-1))];
        }
        return 
$strAlphaNumeric;    
    }
?>