Important functions: file upload, get file name, get file size, random new file name, get file type, Picture Natural thumbnail, return the thumbnail file name, return the uploaded file name, returns the path of the uploaded file.
Important functions:
File upload, get file name, get file size, random new file name, get file type, Picture Natural thumbnail, return the thumbnail file name, return the uploaded file name, returns the path of the uploaded file.
//----------------------------------------------------------------------
// Keep this statement during forwarding. this statement does not affect your speed!
// ******************* IEB Upload class v1.1 *************** ******************
// By Lu Weihua
// Website:Http://www.iebsoft.cn
// Email: yagas60@21cn.com
// Copyright statement: copyright, open source code, and free use of all types of applications. However, the corrected files must be modified.
// Send a copy to the author.
//************************************** *********************************
//
Class ieb_upload {
Var $ FormName; // file domain name
Var $ Directroy; // upload to the Directory
Var $ MaxSize; // maximum upload size
Var $ CanUpload; // whether the file can be uploaded
Var $ doUpFile; // name of the uploaded file
Var $ sm_File; // The name of the thumbnail.
Var $ Error; // Error parameter
Function ieb_upload ($ formName = '', $ dirPath ='', $ maxSize = 2097152) // (1024*2) * 1024 = 2097152 is 2 M
{
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 whether the file exists
Function scanFile ()
{
Global $ FormName, $ Error, $ CanUpload;
If ($ CanUpload ){
$ Scan = is_readable ($ _ FILES [$ FormName] ['name']);
If ($ scan ){
$ Error = 2;
}
Return $ scan;
}
}
// Get the file size
Function getSize ($ format = 'B ')
{
Global $ FormName, $ Error, $ CanUpload;
If ($ CanUpload ){
If ($ _ FILES [$ FormName] ['size'] = 0 ){
$ Error = 3;
$ CanUpload = false;