php文件上传的时候如何把jpeg变成jpg。
else{$sparr=Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","im...
else
{
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","image/wbmp");
if(!in_array($_FILES['imgfile'.$i]['type'],$sparr))
{
continue;
}
$filename = MemberUploads('imgfile'.$i,'',$cfg_ml->M_ID,'image','',0,0,true);
if($filename!='')
{
SaveUploadInfo($title,$filename,1);
}
//缩图
if($pagestyle > 1)
{
$litpicname = GetImageMapDD($filename,$ddmaxwidth);
if($litpicname != '')
{
SaveUploadInfo($title.' 小图',$litpicname,1);
}
}
else
{
$litpicname = $filename;
}
$imgfile = $cfg_basedir.$filename;
if(is_file($imgfile))
{
$iurl = $filename;
$info = '';
$imginfos = @getimagesize($imgfile,$info);
$imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
}
}
怎么样才可以在这段代码中把上传的jpeg变成jpg,改扩展名或格式转换都可以 展开
{
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","image/wbmp");
if(!in_array($_FILES['imgfile'.$i]['type'],$sparr))
{
continue;
}
$filename = MemberUploads('imgfile'.$i,'',$cfg_ml->M_ID,'image','',0,0,true);
if($filename!='')
{
SaveUploadInfo($title,$filename,1);
}
//缩图
if($pagestyle > 1)
{
$litpicname = GetImageMapDD($filename,$ddmaxwidth);
if($litpicname != '')
{
SaveUploadInfo($title.' 小图',$litpicname,1);
}
}
else
{
$litpicname = $filename;
}
$imgfile = $cfg_basedir.$filename;
if(is_file($imgfile))
{
$iurl = $filename;
$info = '';
$imginfos = @getimagesize($imgfile,$info);
$imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
}
}
怎么样才可以在这段代码中把上传的jpeg变成jpg,改扩展名或格式转换都可以 展开
1个回答
展开全部
$filename = MemberUploads('imgfile'.$i,'',$cfg_ml->M_ID,'image','',0,0,true);
//如果MemberUploads函数已经上传完图片了,那你需要copy一份
$newFileName = str_replace('.jpeg', '.jpg', strtolower($filename));
$oldFile = $cfg_basedir . $filename;
$newFile = $cfg_basedir . $newFileName;
copy($oldFile, $newFile);
if ($newFileName) {
SaveUploadInfo($title, $newFileName, 1);
}
//如果MemberUploads函数没上传完图片,是SaveUploadInfo处理的话
if($filename!='')
{
$filename = str_replace('.jpeg', '.jpg', strtolower($filename));
SaveUploadInfo($title, $filename, 1);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |