search
HomePHP LibrariesOther librariesPHP encapsulated image upload class
PHP encapsulated image upload class
<?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

Disclaimer

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

Completely encapsulated php upload file classCompletely encapsulated php upload file class

25Jul2016

Completely encapsulated php upload file class

PHP encapsulated single file upload classPHP encapsulated single file upload class

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.

PHP file upload class and PHP encapsulated multi-file upload class sharingPHP file upload class and PHP encapsulated multi-file upload class sharing

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.

Image upload website php image upload class codeImage upload website php image upload class code

29Jul2016

Image upload website: Image upload website php Image upload class code: Let’s start with a simple one: Copy the code as follows:

Free image upload PHP image upload class with image displayFree image upload PHP image upload class with image display

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.

PHP encapsulated connection Mysql class and usage analysisPHP encapsulated connection Mysql class and usage analysis

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.

See all articles