php教程|PHP源码
nbsp,quot,file,name,FILES
php教程-PHP源码
本代码的功能是把你要上传的图片保存到服务器,然后再把当前图重按比例生成一个小的缩略图哦。
ec(2); if($_FILES[‘image’][‘size’]){
if($_FILES[‘image’][‘type’] == “image/pjpeg”){
$im = @imagecreatefromjpeg($_FILES[‘image’][‘tmp_name’]);
$n_bmp.=’.jpg’;
}elseif($_FILES[‘image’][‘type’] == “image/x-png”){
$im = @imagecreatefrompng($_FILES[‘image’][‘tmp_name’]);
$n_bmp.=’.jpg’;
}elseif($_FILES[‘image’][‘type’] == “image/gif”){
$im = @imagecreatefromgif($_FILES[‘image’][‘tmp_name’]);
$n_bmp.=’.jpg’;
}
ResizeImage($im,8888,8888,$n_bmp);
ImageDestroy ($im);
$n_tag =1;
萌宝投票源码,打开vscode屏幕变绿,ubuntu 安装内核,tomcat 端口 转发,高效sqlite,流行网页设计,win7 iis 数据库连接出错,云免需要什么服务器,oa办公自动化系统插件,o2oa用的什么前端框架,爬虫制表,php utc,seo商业,springboot跳转无效,php提取b标签,网站前台模板设计,如何将网页免费制作app,b2b模板,广州高端品牌网站建设后台管理便捷,js调整页面大小,学生学籍管理系统asp,简单安卓程序lzw
}
无线投屏源码,ubuntu 虚拟串口对,Python网络爬虫面试,php headers,淄博seo开发lzw
function Uploadfile($str){
cpuset源码,vscode微软版 java版,ubuntu进入界面命令,tomcat9.0配置,boa sqlite,网页设计软件视频教程,调用数据库sql语句,网站怎么挂服务器,电话插件,oweb前端框架,艳丽的爬虫,php diff,域名seo查询,springboot 单侧,dede tag标签多选,网站整站图片下载,中文网页模板html百度云,个人音乐站模板,phpwind后台模板,用户动画页面,学生信息管理系统asp源代码,自动生成表白程序源码lzw
$save_path = ‘./product/’;//文件保存目录路径
$ext_arr = array(‘rar’,’zip’,’jpg’,’gif’,’png’,’bmp’);//定义允许上传的文件扩展名
$max_size = 1000000;//最大文件大小
$file_rand =”;
$file_ext =”;
@mkdir($save_path, 0777); //更改目录权限
if ($_FILES[$str][‘name’]) {//有上传文件时
$file_name = $_FILES[$str][‘name’];//原文件名
$tmp_name = $_FILES[$str][‘tmp_name’];//服务器上临时文件名
$file_size = $_FILES[$str][‘size’];//文件大小
if (@is_dir($save_path) === false) {//检查目录
alert(“上传目录不存在。”,”);
}
if (@is_writable($save_path) === false) {//检查目录写权限
alert(“上传目录没有写权限。”,”);
}
if (@is_uploaded_file($tmp_name) === false) {//检查是否已上传
alert(“临时文件可能不是上传文件。”,”);
}
if ($file_size > $max_size) {//检查文件大小
alert(“上传文件大小超过限制。”,”);
}
$temp_arr = explode(“.”, $file_name);//获得文件扩展名
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);
$file_rand= md5(date(“Y-m-d”));
if (in_array($file_ext, $ext_arr) === false) {//检查扩展名
alert(“上传文件扩展名是不允许的扩展名。”,”);
}
if (move_uploaded_file($tmp_name, $save_path.$file_rand.’.’.$file_ext) === false) {//移动文件
alert(“上传文件失败。”,”);
}
}
return $save_path.$file_rand.’.’.$file_ext;
}
function ResizeImage($im,$maxwidth,$maxheight,$name){
$width = imagesx($im);
$height = imagesy($im);
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
if($maxwidth && $width > $maxwidth){
$widthratio = $maxwidth/$width;
$RESIZEWIDTH=true;
}
if($maxheight && $height > $maxheight){
$heightratio = $maxheight/$height;
$RESIZEHEIGHT=true;
}
if($RESIZEWIDTH && $RESIZEHEIGHT){
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
}elseif($RESIZEWIDTH){
$ratio = $widthratio;
}elseif($RESIZEHEIGHT){
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists(“imagecopyresampled”)){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
ImageJpeg ($newim,’./product_e/’.$name);
ImageDestroy ($newim);
}else{
ImageJpeg ($im,’./product_e/’.$name);
}
}