有缩略图功能 但是 感觉不全面,而且有点问题,继续学习,将来以后修改下
<form action="<" enctype="multipart/form-data" method="post" ><input type="text" name="name" /><input type="file" name="file" /><input type="submit" name='submit' value="提交" ></form> <"file",$filemax=20000000,$filepath="./Uploads",$fileflag=true,$fileExt=array('jpg','exe'),$fileMine=array('image/jpeg')) { $this->filename=$filename; $this->fileinfo=$_FILES[$this->filename]; $this->filemax=$filemax; $this->filepath=$filepath; $this->fileflag=$fileflag; $this->fileExt=$fileExt; $this->fileMine=$fileMine; //var_dump($this->filename); } //错误判断 public function UpError(){ if($this->fileinfo['error']>0){ switch($this->fileinfo['error']) { case 1: $this->fileerror="上传文件大小超过服务器允许上传的最大值,php.ini中设置upload_max_filesize选项限制的值 "; break; case 2: $this->fileerror="上传文件大小超过HTML表单中隐藏域MAX_FILE_SIZE选项指定的值"; break; case 3: $this->fileerror="文件部分被上传"; break; case 4: $this->fileerror="没有选择上传文件"; break; case 5: $this->fileerror="未找到临时目录"; break; case 6: $this->fileerror="文件写入失败"; break; case 7: $this->fileerror="php文件上传扩展没有打开 "; break; case 8: $this->fileerror=""; break; } return false; } return true; } //检测文件类型 public function UpMine(){ if(!in_array($this->fileinfo['type'],$this->fileMine)) { $this->error="文件上传类型不对"; return false; } return true; } //检测文件格式 public function UpExt(){ $this->ext=pathinfo($this->fileinfo['name'],PATHINFO_EXTENSION); //var_dump($ext); if(!in_array($this->ext,$this->fileExt)){ $this->fileerror="文件格式不对"; return false; } return true; } //检测文件路径 public function UpPath(){ if(!file_exists($this->filepath)){ mkdir($this->filepath,0777,true); } } //检测文件大小 public function UpSize(){ $max=$this->fileinfo['size']; if($max>$this->filemax){ $this->fileerror="文件过大"; return false; } return true; } //检测文件是否HTTP public function UpPost(){ if(!is_uploaded_file($this->fileinfo['tmp_name'])){ $this->fileerror="恶意上偿还"; return false; } return true; } //文件名防止重复 public function Upname(){ return md5(uniqid(microtime(true),true)); } //图片缩略图 public function Smallimg($x=100,$y=100){ $imgAtt=getimagesize($this->path); //图像宽,高,类型 $imgWidth=$imgAtt[0]; $imgHeight=$imgAtt[1]; $imgext=$imgAtt[2]; //等比列缩放 if(($x/$imgWidth)>($y/$imgHeight)){ $bl=$y/$imgHeight; }else{ $bl=$x/$imgWidth; } $x=floor($imgWidth*$bl); //缩放后 $y=floor($imgHeight*$bl); $images=imagecreatetruecolor($x,$y); $big=imagecreatefromjpeg($this->path); imagecopyresized($images,$big,0,0,0,0,$x,$y,$imgWidth,$imgWidth); switch($imgext){ case 1: $imageout=imagecreatefromgif($this->path); break; case 2: $imageout=imagecreatefromjpeg($this->path); break; case 3: $imageout=imagecreatefromgif($this->path); break; } $im=imagejpeg($images,$this->path); } //文件双传 public function uploads() { if($this->UpError()&&$this->UpMine()&&$this->UpExt()&&$this->UpSize()&&$this->UpPost()){ $this->UpPath(); $names=$this->Upname(); $this->path=$this->filepath.'/'. $names.'.'.$this->ext; if(move_uploaded_file($this->fileinfo['tmp_name'], $this->path)){ return $this->path; }else{ $this->fileerror="上传失败"; } }else{ exit("<b>".$this->fileerror."</b>"); } } } <"content-type:imagejpeg"); header("Content-type:text/html;charset=utf-8"); require 'list.php'; $u=new upload(); $a=$u->uploads(); $c=$u->Smallimg(); echo "<img src={$a} />"; echo "<img src={$c} />"; "utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Examples</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> </head> <body> <form action="ce.php" enctype="multipart/form-data" method="post" > <input type="text" name="name" /><input type="file" name="file" /> <input type="submit" name='submit' value="提交" > </form> </body> </html>
以上所述是小编给大家介绍的PHP上传图片类显示缩略图功能的相关知识,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年09月24日
2024年09月24日
- 国风大师纯音系列《古筝仙子 常静演奏 十指弹一》1CD[FLAC][919MB]
- DasKapital-OneMustHaveChaosInsidetoGiveBirthtoaDancingStar(2024)[24-44.1]WAV
- 王菲.1999-《只爱陌生人》日本东芝版[低速原抓WAV+CUE]
- 张小英1987-金奖金曲第一集[新加坡版][WAV+CUE]
- 鹿晗.2015-重启【海蝶】【FLAC分轨】
- 张芸京.2012-小女孩【金牌大风】【WAV+CUE】
- 余天.2002-雄狮魅力金曲2CD(南方金点系列)【南方】【WAV+CUE】
- 银霞.1982-《结·SAYYESMYBOY》台湾复刻版[WAV+CUE]
- 梁汉文1993-火热动感[引进版][WAV+CUE]
- 梁汉文2008-EDMONDHITS48[香港]3CD[WAV+CUE]
- 国风大师纯音系列《童丽-[渭城曲]》1CD[WAV分轨][593.5MB]
- 国风大师纯音系列《许菱子《烧筝2》古筝曲集》1CD[WAV分轨][1.3GB]
- 王子异《1996 Part.2》[320K/MP3][18.29MB]
- 群星.1994-宝丽金最倾情3CD【宝丽金】【WAV+CUE】
- 乐俊亨.2024-同泪【CharioticMusic】【FLAC分轨】