Main functions:
File upload, get the file name, get the file size, randomly generate a new file name, get the file type, generate a thumbnail for the image, return the thumbnail file name, return the file name of the file generated after uploading, return the file path after uploading
class ieb_upload{
var $FormName; //File domain name
var $Directroy; //Upload to directory
var $MaxSize; //Maximum upload size
var $CanUpload; //Whether it can be uploaded
var $doUpFile; //Uploaded file name
var $sm_File; //Thumbnail name
var $Error; //Error parameter
function ieb_upload($formName='', $dirPath='', $maxSize=2097152) //(1024*2)*1024=2097152 is 2M
{
global $FormName, $Directroy, $MaxSize, $CanUpload, $Error, $doUpFile, $sm_File;
//Initialize various parameters
$FormName = $formName;
$MaxSize = $maxSize;
$CanUpload = true;
$doUpFile = '';
$sm_File = '';
$Error = 0;
if ($formName == ''){
$CanUpload = false;
$Error = 1;
break;
}
if ($dirPath == ''){
$Directroy = $dirPath;
}else{
$Directroy = $dirPath.'/';
}
}
//Check if the file exists
function scanFile()
{
global $FormName, $Error, $CanUpload;
if ($CanUpload){
$scan = is_readable($_FILES[$FormName]['name']);
if ($scan){
$Error = 2;
}
return $scan;
}
}
//Get file size
function getSize($format = 'B')
{
global $FormName, $Error, $CanUpload;
if ($CanUpload){
if ($_FILES[$FormName]['size'] == 0){
$Error = 3;
$CanUpload = false;
}
switch ($format){