正文 1791字数 161,280阅读

<?php session_start(); if(!$_SESSION['admin']) exit('Error:bannnergly201111251'); //上传类型 $uptypes=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/x-png'); $max_file_size=4900000; $destination_folder=dirname(__FILE__).'/../upload/banner/'; //文件状态判断 $sy=@$_GET['sy']; $sy_arr=array('1','2','3'); $n=@$_GET['n']; $n_arr=array('zby','gny','cjy'); if(!in_array($sy, $sy_arr) && !in_array($n, $n_arr)) exit(); $sys=in_array($n, $n_arr)?$n:'sy'; if ($_SERVER['REQUEST_METHOD'] == 'POST'){ $file = $_FILES['upfile']; $filename=$file['tmp_name']; if (!is_uploaded_file($_FILES['upfile']['tmp_name'])) exit; if($max_file_size < $file['size']) exit; if(!in_array($file['type'], $uptypes)) exit; $destination = $destination_folder.$sys.$sy.".gif"; if(!move_uploaded_file ($filename, $destination)) exit; //调整上传图片的大小 $destinations = $destination_folder.$sys.'m'.$sy.".gif"; $size=getimagesize($destination); $width=200; $height=100; if($size[2]==1)$im_in=imagecreatefromgif($destination); if($size[2]==2)$im_in=imagecreatefromjpeg($destination); if($size[2]==3)$im_in=imagecreatefrompng($destination); $im_out=imagecreatetruecolor($width,$height); imagecopyresampled($im_out,$im_in,0,0,0,0,$width,$height,$size[0],$size[1]); imagejpeg($im_out,$destinations); chmod($destinations,0744); imagedestroy($im_in); imagedestroy($im_out); //if(!move_uploaded_file ($destination, $destinations)) exit; } echo "<script>window.location.href='../admin.php?admin=$sys';</script>"; exit();
Run code
Cut to clipboard