PHP上传类,分享给大家,不足之处请见谅!该如何处理
PHP上传类,分享给大家,不足之处请见谅!
不足之处请高手见谅!
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*** 文件上传类 kangyangyang 2010-06-07* $loadfile 要上传的文件的文件域* $loadpath 文件存放路径* $loadhold 保留文件原名* $loadsize 文件大小限制 //默认是2048KB* $loadtype 文件类型限制 //默认支持 jpg|jpeg|gif|png|txt|rar|zip**/class uploadfile{private $loadfile;private $loadpath;private $loadsize;private $loadtype;private $loadhold = false;private $chkfile = true;private $file_name;private $extend_type;private $set_name;private $set_size;private $set_path;private $set_create_name;private $get_error;//构造函数function __construct($loadfile,$loadpath,$loadhold = false,$loadsize="2097152",$loadtype="jpg|jpeg|gif|png|txt|rar|zip"){ $this->loadfile = $loadfile; $this->loadpath = $loadpath; $this->loadsize = $loadsize; $this->loadtype = $loadtype; $this->loadhold = $loadhold; $this->filecheck();}//文件上传function filecheck(){ $filename = $_FILES[$this->loadfile]['name']; //文件名 $filetype = $_FILES[$this->loadfile]['type']; //文件类型 $filesize = $_FILES[$this->loadfile]['size']; //文件大小 $filepath = $_FILES[$this->loadfile]['tmp_name']; //临时文件 $fileerror= $_FILES[$this->loadfile]['error']; //错误代码 if($fileerror loadsize >= $filesize){ $this->set_size = $filesize; $ext = explode(".",$filename); $this->set_name = $ext; $ext_type = strtolower($ext[count($ext)-1]); $this->extend_type = $ext_type; $chk_type = explode("|",$this->loadtype); if(in_array($ext_type,$chk_type)){ $f_path = $this->get_folder(); $this->set_create_name = $createname = time().rand(1,9999); $this->file_name = $createname.".".$ext_type; if($this->loadhold){ $file_path = $f_path.$filename; $this->set_path = $file_path; }else{ $file_path = $f_path.$this->file_name; $this->set_path = $file_path; } $ckfile = move_uploaded_file($filepath,$file_path); if(!$ckfile){ $this->chefile = false; } }else{ $this->chkfile = false; } }else{ $this->chkfile = false; } }else{ $this->chkfile = false; $this->get_error = $fileerror; }}//生成的文件名function get_CreateName(){ if($this->CheckFile()){ if(!$this->loadhold){ return $this->set_create_name; } }}//返回文件夹路径function get_folder(){ if($this->CheckFile()){ if(!file_exists($this->loadpath)){ mkdir($this->loadpath,0777,true); chmod($this->loadpath,0777); } return $this->loadpath; }}//文件扩展名function get_type(){ if($this->CheckFile()){ return $this->extend_type; }}//文件名"不包括扩展名"function get_name(){ if($this->CheckFile()){ $filename = $this->set_name; unset($filename[count($filename)-1]); return implode(".",$filename); }}//返回文件大小function get_size(){ if($this->CheckFile()){ return $this->set_size; }}//返回文件全路径function get_path(){ if($this->CheckFile()){ return $this->set_path; }}//文件是否上传成功function CheckFile(){ return $this->chkfile;}//获取错误代码function get_error(){ if($this->CheckFile()){ return $this->get_error; }}}
------解决方案--------------------
不错,谢谢
------解决方案--------------------
------解决方案--------------------
不错,收藏
------解决方案--------------------
太牛了,收藏下

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

In Java, private means "private" and is an access control modifier used to modify classes, properties and methods. Class members modified with private can only be accessed and modified by the methods of the class itself, and cannot be accessed and referenced by any other class (including subclasses of the class); therefore, the private modifier has the highest level of protection.

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table
