1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php实现从上传文件创建缩略图办法

php实现从上传文件创建缩略图办法

时间:2021-07-28 14:59:15

相关推荐

php实现从上传文件创建缩略图办法

php教程|php手册

php,上传文件,创建缩略图

php教程-php手册

易语言qq批量登陆源码,vscode怎么添加图片,ubuntu 死机log,怎么查看tomcat几位,数据库爬虫创建多表爬虫,php 获取 pid,江干区百度seo服务,个人主页网站源代码吧,ecshop app模板lzw

这篇文章主要介绍了php实现从上传文件创建缩略图的方法,涉及php操作上传文件及图片操作的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

怎么获取一个静态网站源码,ubuntu终端初始目录,tomcat如何拒绝请求,华为搜索爬虫,php打开ppt,靠谱的杭州抖音seo优化公司lzw

付款下载系统源码,ubuntu网卡驱动重置,Tomcat下连接选择题,判断爬虫断开连接,php怎么发送文件夹,seo图文消息lzw

本文实例讲述了php实现从上传文件创建缩略图的方法。分享给大家供大家参考。具体实现方法如下:

102400){

$error=1;

$msg = “The photo is over 100kb. Please try again.”;

}

////////////////////////////////

// CHECK TYPE (IE AND OTHERS) //

if ($userfile_type=”image/pjpeg”){

if ($userfile_type!=”image/jpeg”){

$error=1;

$msg = “The photo must be JPG”;

}

}

//////////////////////////////

//CHECK WIDTH/HEIGHT //

if ($large_width!=600 or$large_height!=400){

$error=1;

$msg = “The photo must be 600×400 pixels”;

}

///////////////////////////////////////////

//CREATE THUMB / UPLOAD THUMB AND PHOTO ///

if ($error1){

$image = $userfile_name; //if you want to insert it to the database

$pic = imagecreatefromjpeg($userfile);

$small = imagecreatetruecolor($small_width,$small_height);

imagecopyresampled($small,$pic,0,0,0,0, $small_width, $small_height, $large_width, $large_height);

if (imagejpeg($small,”path/to/folder/to/upload/thumb”.$userfile_name, 100)){

$large = imagecreatetruecolor($large_width,$large_height);

imagecopyresampled($large,$pic,0,0,0,0, $large_width, $large_height, $large_width, $large_height);

if (imagejpeg($large,”path/to/folder/to/upload/photo”.$userfile_name, 100))

{}

else {$msg=”A problem has occured. Please try again.”; $error=1;}

}

else {

$msg=”A problem has occured. Please try again.”; $error=1;

}

}

//////////////////////////////////////////////

/// If everything went right a photo (600×400) and

/// a thumb(120×90) were uploaded to the given folders

}

?>

create thumbSelect Photo:

</body

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。