<?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='\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6587\u4ef6';
return false;
}
//判断文件是否上传到临时目录成功
switch($file['error']){
case 1:这是一个php封装的图片上传类,需要的朋友可以下载使用
评论0
最新资源