⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.inc.php

📁 支持中、英、繁三种语言; 3、提供9套风格任意转换; 4、内嵌全球免费可视电话系统
💻 PHP
字号:
<?php
class upload {
	var $PIC_FILE;
	var $cls_upload_dir; 				// Directory to upload to
	var $cls_max_filesize; 				// max file size (must be set in form)
	var $cls_filename;				// Name of the uploaded file
	var $cls_filesize; 				// file size
	var $cls_arr_ext_accepted; 			// Type of file we will accept.
	var $cls_copyCode;				// error code
	var $cls_overWrite;	 			//Overwrite the file if exists

	function upload($inputFileName, $destDir = null, $rename = true) {
		//
		global $f;
		$this->cls_upload_dir = $destDir;
		$this->PIC_FILE = $f;
		//$this->cls_upload_dir = $destDir;
		$this->cls_filename = $inputFileName;
		$this->cls_max_filesize = 500000;//500K,Max
		$this->cls_arr_ext_accepted = array(	
		".png",
		".gif",
		".jpg",
		".jpeg",
		".tif",
		".PNG",
		".GIF",
		".JPG",
		);
	}
	
	function checkExtension()
	{
		return( in_array( $this->get_extension( $this->cls_filename ), $this->cls_arr_ext_accepted ));
	}
	
	function get_extension($filename)
	{
		// $this->cls_filename;
		//echo "<br>houzhui".fileext($filename);
		return fileext($filename);
	}
	
  	function checkFileSize()
	{
		return( !($this->PIC_FILE['size'] > $this->cls_max_filesize) );
	}
	
	   	/** removeFile()
   	** Remove a remote file in upload dir(if we have perms)
   	** @returns 1 if file was removed, 0 if an error occurred
   	**/
   	function removeFile( $file )
   	{
   		//check if file exists
		if (file_exists($this->cls_upload_dir."/".$file))
		{
			if( @unlink($this->cls_upload_dir."/".$file) )
			{
				return(1);
			}
			else
			{
				return(0);
			}
		}
		else
		{
			return (0);
		}
   	}
   	
	function checkImage()
	{
		if(!$this->checkExtension()){
			//echo "<br>类型不支持";
			return false;
		}elseif(!$this->checkFileSize()){
			//echo "2";
			return false;
		}elseif(!is_uploaded_file($this->PIC_FILE['tmp_name'])){
			//echo "3";
			return false;
		}else{
			return true;
		}
	}
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -