php 上传中修改扩展名jpeg改jpg 50
这是MemberUploads这个方法,要怎么改,求救~~functionMemberUploads($upname,$handname,$userid=0,$utype...
这是MemberUploads这个方法,要怎么改,求救~~
function MemberUploads($upname,$handname,$userid=0,$utype='image',$exname='',$maxwidth=0,$maxheight=0,$water=false,$isadmin=false)
{
global $cfg_imgtype,$cfg_mb_addontype,$cfg_mediatype,$cfg_user_dir,$cfg_basedir,$cfg_dir_purview;
//当为游客投稿的情况下,这个 id 为 0
if(empty($userid) ) $userid = 0;
if(!is_dir($cfg_basedir.$cfg_user_dir."/$userid"))
{
MkdirAll($cfg_basedir.$cfg_user_dir."/$userid", $cfg_dir_purview);
CloseFtp();
}
//有上传文件
$allAllowType = str_replace('||', '|', $cfg_imgtype.'|'.$cfg_mediatype.'|'.$cfg_mb_addontype);
if(!empty($GLOBALS[$upname]) && is_uploaded_file($GLOBALS[$upname]))
{
$nowtme = time();
$GLOBALS[$upname.'_name'] = trim(preg_replace("#[ \r\n\t\*\%\\\/\?><\|\":]{1,}#",'',$GLOBALS[$upname.'_name']));
//源文件类型检查
if($utype=='image')
{
if(!preg_match("/\.(".$cfg_imgtype.")$/", $GLOBALS[$upname.'_name']))
{
ShowMsg("你所上传的图片类型不在许可列表,请上传{$cfg_imgtype}类型!",'-1');
exit();
}
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","image/wbmp");
$imgfile_type = strtolower(trim($GLOBALS[$upname.'_type']));
if(!in_array($imgfile_type, $sparr))
{
ShowMsg('上传的图片格式错误,请使用JPEG、GIF、PNG、WBMP格式的其中一种!', '-1');
exit();
}
}
else if(!preg_match("/\.(".$allAllowType.")$/", $GLOBALS[$upname.'_name']))
{
ShowMsg("你所上传的文件类型不被允许!",'-1');
exit();
}
//加水印或缩小图片
if($utype=='image')
{
include_once(DEDEINC.'/image.func.php');
if($maxwidth>0 || $maxheight>0)
{
ImageResize($cfg_basedir.$filename, $maxwidth, $maxheight);
}
else if($water)
{
WaterImg($cfg_basedir.$filename);
}
}
return $filename;
}
}
} 展开
function MemberUploads($upname,$handname,$userid=0,$utype='image',$exname='',$maxwidth=0,$maxheight=0,$water=false,$isadmin=false)
{
global $cfg_imgtype,$cfg_mb_addontype,$cfg_mediatype,$cfg_user_dir,$cfg_basedir,$cfg_dir_purview;
//当为游客投稿的情况下,这个 id 为 0
if(empty($userid) ) $userid = 0;
if(!is_dir($cfg_basedir.$cfg_user_dir."/$userid"))
{
MkdirAll($cfg_basedir.$cfg_user_dir."/$userid", $cfg_dir_purview);
CloseFtp();
}
//有上传文件
$allAllowType = str_replace('||', '|', $cfg_imgtype.'|'.$cfg_mediatype.'|'.$cfg_mb_addontype);
if(!empty($GLOBALS[$upname]) && is_uploaded_file($GLOBALS[$upname]))
{
$nowtme = time();
$GLOBALS[$upname.'_name'] = trim(preg_replace("#[ \r\n\t\*\%\\\/\?><\|\":]{1,}#",'',$GLOBALS[$upname.'_name']));
//源文件类型检查
if($utype=='image')
{
if(!preg_match("/\.(".$cfg_imgtype.")$/", $GLOBALS[$upname.'_name']))
{
ShowMsg("你所上传的图片类型不在许可列表,请上传{$cfg_imgtype}类型!",'-1');
exit();
}
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","image/wbmp");
$imgfile_type = strtolower(trim($GLOBALS[$upname.'_type']));
if(!in_array($imgfile_type, $sparr))
{
ShowMsg('上传的图片格式错误,请使用JPEG、GIF、PNG、WBMP格式的其中一种!', '-1');
exit();
}
}
else if(!preg_match("/\.(".$allAllowType.")$/", $GLOBALS[$upname.'_name']))
{
ShowMsg("你所上传的文件类型不被允许!",'-1');
exit();
}
//加水印或缩小图片
if($utype=='image')
{
include_once(DEDEINC.'/image.func.php');
if($maxwidth>0 || $maxheight>0)
{
ImageResize($cfg_basedir.$filename, $maxwidth, $maxheight);
}
else if($water)
{
WaterImg($cfg_basedir.$filename);
}
}
return $filename;
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询