您好,欢迎访问一九零五行业门户网

为啥上传图片中含有透明通道,图片就会变成黑色

为什么上传图片中含有透明通道,图片就会变成黑色?
p.s. 改的图片上传类原文地址:http://blog.csdn.net/a957651480/article/details/23124257
chk_err(-1);       //无传入控件名
}else{
$this->inputname = $inputname;
}
if(!empty($allowtype)) $this->allowtype = $allowtype;
if(!empty($allowsize)) $this->allowsize = $allowsize;
if(!empty($savedir)) $this->savedir = $savedir;
if(!empty($isrename)) $this->isrename = $isrename;
}
function is_uploaded(){
if(empty($_files[$this->inputname]['name'])){
$this->chk_err(4);    //没有文件被上传
}else{
if(is_uploaded_file($_files[$this->inputname]['tmp_name'])){
return true;
}else{
$this->chk_err(-2);       //文件上传不合法
}
}
}
function chk_type(){
if(!in_array($_files[$this->inputname]['type'],$this->allowtype)){
$this->chk_err(-3);         //上传的文件类型不被允许
}else{
return true;
}
}
function chk_size(){
if($_files[$this->inputname]['size'] > $this->allowsize){
$this->chk_err(-4);          //上传的文件过大
}else{
return true;
}
}
function move_uploaded(){        //移动上传文件
if(!$this->is_uploaded()){
return false;
}
if(!$this->chk_size()){
return false;
}
if(!$this->chk_type()){
return false;
}
//重命名
if($this->isrename){
$arrtmp = pathinfo($_files[$this->inputname]['name']);
$extension = strtolower($arrtmp['extension']);
$file_newname = $this->filename; //重命名新文件
}else{
$file_newname = $_files[$this->inputname]['name'];
}
if(!file_exists($this->savedir)){       //判断保存目录是否存在
mkdir($this->savedir,0777,true);    //建立保存目录
}
//移动文件
$result = move_uploaded_file($_files[$this->inputname]['tmp_name'],$this->savedir./.$file_newname);
if($result){
$path = $this->savepath = $this->savedir./.$file_newname; //文件的成功保存路径
return $path;
}else{
$this->chk_err($_files[$this->inputname]['error']);
}
}
//判断出错信息
function chk_err($errid){
$this->errid = $errid;
switch($this->errid){
case -4:
$this->errmsg = '只能上传1m以内的图片 | [返回]';
break;
case -3:
$this->errmsg = '这不是一张图片 | [返回]';
break;
case -2:
$this->errmsg = '文件上传不合法 | [返回]';
break;
case -1:
$this->errmsg = '无控件名传入 | [返回]';
break;
case 1:
$this->errmsg = '上传的文件超出了php.ini中upload_max_filesize设定的最大值 | [返回]';
break;
case 2:
$this->errmsg = '上传文件的大小超过了html表单中max_file_size选项指定的值 | [返回]';
break;
case 3:
$this->errmsg = '文件只有部分被上传 | [返回]';
break;
case 4:
$this->errmsg = '请选择一张图片 | [返回]';
break;
default:
break;
}
return false;
}
function get_errmsg(){

其它类似信息

推荐信息