<?php //封装php中的单文件(图片)上传类 header('content-type:text/html;charset=utf-8'); class Upload{ //定义一个属性,专门保存错误信息 public static $error; //文件转移的方法 public function uploadFile($file,$size,$path){ if(!is_dir($path)){ $this->mkPath($path); } $allow=array('image/jpeg','image/jpg','image/png','image/gif'); //首先判断文件是否已上传到临时目录 if(!is_array($file)){ Upload::$error='不是一个有效的文件'; return false; } //判断文件是否上传到临时目录成功 switch($file['error']){ case 1:
This is a PHP-encapsulated image upload class. Friends who need it can download and use it
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
31May2018
This article mainly introduces the single file (image) upload class encapsulated in PHP, and analyzes the related processing skills of PHP image file upload operation in the form of a complete example. Friends in need can refer to it.
10Feb2018
This article mainly shares with you the relevant code of the PHP file upload class and the PHP encapsulated multi-file upload class. It has a certain reference value. Interested friends can refer to it. I hope it can help everyone.
29Jul2016
Image upload website: Image upload website php Image upload class code: Let’s start with a simple one: Copy the code as follows: //http://www.jb51.net class upLoad{ public $length; //Limit file size public $file; //Determine whether this class is used for image upload or file upload public $fileName; //File name public $fileTemp; //Upload temporary file public $fileSize; //Upload file size pub
29Jul2016
Free image upload: Free image upload PHP image upload class with image display: This is a PHP file upload class with image display. In fact, it can be made into a function. But it is more fun to make it into a class.~~~~ It should be Use JS to verify the type of uploaded files. But I am too lazy to do it.
21Dec2016
This article mainly introduces the connection MySQL class and usage encapsulated by PHP. Based on PHP, it encapsulates simple MySQL database connection, query, traversal and other skills, and also explains its specific usage. Friends who need it can refer to it.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images