Home > Article > Backend Development > PHP file upload class (this class supports single or multiple file uploads) (1/2)_PHP tutorial
PHP file upload class (this class supports single or multiple file uploads) /*** Class name: upfile * Function: Process file uploads * Description: This class handles single or multiple file uploads. When using this class, you only need to instantiate the class * Example:
/php tutorial file upload class (the Class supports single or multiple file uploads)
< body>
//php file upload class (this class supports single or multiple file uploads)
/**
* Class name: upfile
* Function: processing File upload
* Note that this class handles single or multiple file uploads. When using this class, you only need to instantiate the class
* Example:
* $up = upfile()
* $up->update_file($_file['filename'])
*
* $up->update_file function returns an array, which is multi-dimensional data if multiple files are uploaded.
* Array content:
* $fileinfo['file_size'] Upload file size
* $fileinfo['file_suffix'] Upload file type
* $fileinfo['file_name'] Upload The name of the file
* $fileinfo['error'] The error caused by uploading the file
*
*/
class upfile {
public $fcount = 1; = array('jpg','jpeg','gif','png'); //File format
public $fsize = 1024; //File size unit kb
public $fdir = 'www.bkjia .com/'; // File Storage Directory
Public $ ERRORMSG =' '; // Temporary error information generated
*Function name: get_tmp_file($putfile)
*Function: Get the uploaded temporary file name
*@param array $putfile
*@return string $upimg Returns the temporary file name
*/
Function get_tmp_file ($ public) {
if($this->fcount == 1){
$tmpfile = $putfile['tmp_name'];
}else{
for($i=0;$i< $this->fcount;$i++){
$tmpfile[] = $putfile['tmp_name'][$i];
}
}
return $tmpfile;
} 1 2