PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php上传图片生成缩略图(GD库)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

首先来一段简单的PHP上传图片生成缩略图的详细代码分享给大家供大家参,具体内容如下

php;">
<>PHP
function createThumbnail($imageDirectory,$imagename,$thumbDirectory,$thumbWidth,$quality){
$details = getimagesize("$imageDirectory/$imagename") or die('Please only upload images.');
$type = preg_@R_675_9363@ce('@^.+(?<= (.+)$@','$1',$details['mime']);="" eval('$srcimg="imagecreatefrom'.$type.'("$imageDirectory/$imageName");');" $thumbheight="$details[1]" *="" ($thumbwidth="" $details[0]);="" $thumbimg="imagecreatetruecolor($thumbWidth,$thumbHeight);" imagecopyresampled($thumbimg,$srcimg,$thumbheight,$details[0],$details[1]);="" eval('image'.$type.'($thumbimg,"$thumbdirectory/$imagename"'.="" (($type="='jpeg')?',$quality':'').');');" imagedestroy($srcimg);="" imagedestroy($thumbimg);="" }="" foreach="" ($_files["pictures"]["error"]="" as="" $key=""> $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name,"data/$name");
createThumbnail("/LOCATIOn/of/main/image",$name,"/LOCATIOn/to/store/thumb",120,80);
//120 = thumb width :: 80 = thumb quality (1-100)
}
}
?>

大佬总结

以上是大佬教程为你收集整理的php上传图片生成缩略图(GD库)全部内容,希望文章能够帮你解决php上传图片生成缩略图(GD库)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。