<?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
12Jul2016
PHP image upload class with calling method attached. The php image upload class is attached with the calling method. The example in this article is to share the php image upload class for your reference. The specific content is as follows. The calling method: phpheader("Content-Type:text/html; charse
12Jul2016
PHP upload image class and usage examples. PHP upload image class and usage examples. This article describes the PHP image upload class and usage examples. Share it with everyone for your reference, the details are as follows: 1. The class file name is: upclass.php phpclass up
12Jul2016
Complete instance of MSSql operation class encapsulated by PHP, mssql instance encapsulated by PHP. Complete example of PHP encapsulated MSSql operation class, PHP encapsulated mssql example This article describes the PHP encapsulated MSSql operation class. Share it with everyone for your reference, the details are as follows: php/*MSSql operation class
12Jul2016
PHP simple upload class sharing, PHP upload sharing. PHP simple upload class sharing, PHP upload sharing. The example in this article shares the PHP upload class for your reference. The specific content is as follows: phpclass UploadFile{ var $inputName; //Control name var
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