⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uppic_gif.php

📁 php做的一个同学录网站,功能齐全. 后台管理非常方便,有需要的同学可以下载测试.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
// 本函数从源文件取出图象,设定成指定大小,并输出到目的文件
// 源文件格式:gif,jpg,jpe,jpeg,png
// 目的文件格式:jpg
// 参数说明:
// $srcFile 源文件
// $dstFile 目标文件
// $dstW 目标图象宽度
// $dstH 目标图象高度
function makethumb($srcFile,$dstFile,$dstW,$dstH) {
$data = GetImageSize($srcFile,&$info);
switch ($data[2]) {
case 1:
$im = ImageCreateFromGIF($srcFile);
break;
case 2:
$im = imagecreatefromjpeg($srcFile);
break;
case 3:
$im = ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$dstX=0;
$dstY=0;
if ($srcW*$dstH>$srcH*$dstW) { $fdstH=round($srcH*$dstW/$srcW); $dstY=floor(($dstH-$fdstH)/2); $fdstW=$dstW; }
else { $fdstW=round($srcW*$dstH/$srcH); $dstX=floor(($dstW-$fdstW)/2); $fdstH=$dstH; }
$ni=ImageCreate($dstW,$dstH);
$dstX=($dstX<0)?0:$dstX;
$dstY=($dstX<0)?0:$dstY;
$dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX;
$dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY;
$black = ImageColorAllocate($ni, 0,0,0);//填充的背景色你可以重新指定,我用的是黑色
imagefilledrectangle($ni,0,0,$dstW,$dstH,$black);
ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH);
ImageJpeg($ni,$dstFile);//如果你要把图片直接输出到浏览器,
//那么把第二个参数去掉,并用header()函数指定mine类型先
imagedestroy($im);
imagedestroy($ni);
}
?>
<?php
include("pwdtx.php");
include("connect.inc.php");
include("char.inc.php");
if(isset($flag)){
  if($userfile_size>$max_file_size){
?>
<script language="javascript">
<!--
alert("文件大于默认值500K!")
history.back()
//-->
</script>
<?php
  exit();
  }
  $f=date("Ymd").date("His").$userid;
  switch($userfile_type){
      case "image/pjpeg":
         $fname = $f . ".jpg";
         break;
      case "image/gif":
         $fname = $f . ".gif";
         break;
      case "image/x-png":
         $fname = $f . ".png";
         break;
      default:
?>
<script language="javascript">
<!--
alert("上传拒绝,文件类型不允许,请上传*.jpg、*.png文件!")
history.back()
//-->
</script>
<?php
         exit();
     }
     $userfile=dirname($userfile) . "/" . basename($userfile);
  if(copy($userfile, "../upload/photo/" . $fname)){
  $dstW=150;
  $dstH=100;
  $srcFile="../upload/photo/" . $fname;
  $dstFile="../upload/pvpic/"."pv".$fname;
 //@makethumb($srcFile,$dstFile,$dstW,$dstH)or die("error here!!");
 makethumb($srcFile,$dstFile,$dstW,$dstH);

  (isset($pubphoto))?$public=1:$public=0;
  $fromquery=@mysql_query("select name from zmis41197 where studentnumber=".$userid,$conn)or die(mysql_error());
  $fromarray=mysql_fetch_array($fromquery);
  $uploadman=$fromarray["name"];
  $query="insert into album (title,memo,type,size,photofrom,uploadman,datetime,public,filename,pvpic,userid) values ('$title','$memo','$phototype','$userfile_size','$photofrom','$uploadman',NOW(),$public,'$fname',1,$userid)";
  if(isset($checkbox)){
    $updataquery="UPDATE zmis41197 SET photo='".$fname."' WHERE studentnumber=".$userid." LIMIT 1";
    @mysql_query($updataquery,$conn)or die("更新zmis41197表出错!");
  }
      if(mysql_query($query,$conn)){
        // echo "文件".$userfile_name."已发送"."<br>";
        // echo "而且在服务器上此文件已经更名为".$fname."。"."<br>";
        // echo "文件字节大小为:".$userfile_size."<br>";
       //  echo "文件类型是:".$userfile_type."<br>";
         echo "<!-- Fireworks 4.0-->";
         }else{
         echo "<br>".mysql_error()."<br>";
         }
  }else{
?>
<script language="javascript">
<!--
alert("由于系统的安全设置问题或者其他原因,文件上传失败!!")
history.back()
//-->
</script>
<?php
      exit();
    }
//##########

}
?><html>
<head>
 <script language="javascript">
  <!--
  function ok_onclick(){
  var text=""
  if(form1.userfile.value!="" && form1.title.value!="" && form1.memo.value!="" && form1.pubphoto.value!="" && form1.photofrom.value!="") form1.submit()
  else text="你没有填写"
      if (form1.userfile.value=="") text=text+" 照片"
      if (form1.title.value=="") text=text+" 标题"
      if (form1.memo.value=="") text=text+" 简介"
      if (form1.pubphoto.value=="") text=text+" 是否公开"
      if (form1.photofrom.value=="") text=text+" 来源"
  if(form1.userfile.value=="" || form1.title.value=="" || form1.memo.value=="" || form1.pubphoto.value=="" || form1.photofrom.value=="") alert(text)

  }
  //-->
 </script>
<style type="text/css">
<!--
td{font-size:12px;line-height:17px;}
a:active {text-decoration: none;}
a:link {text-decoration: none;}
a:hover{text-decoration: underline;}
a:visited {text-decoration: none;}
BODY{font-size:12px;line-height:17px;SCROLLBAR-FACE-COLOR: #83d160; SCROLLBAR-HIGHLIGHT-COLOR: #CCFF00; SCROLLBAR-SHADOW-COLOR: #CCFF00; SCROLLBAR-3DLIGHT-COLOR: #009900; SCROLLBAR-ARROW-COLOR:  #006600; SCROLLBAR-TRACK-COLOR: ##99FF00; SCROLLBAR-DARKSHADOW-COLOR: #009900; }
-->
</style>
<title>::::上传照片::::</title>
<meta http-equiv="Content-Type" content="text/html;">
<!-- Fireworks 4.0  Dreamweaver 4.0 target.  Created Wed Mar 20 14:48:27 GMT+0800 (?D1ú±ê×?ê±??) 2002-->
</head>
<body bgcolor="#dcf6ce" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#666600" link="#009900" alink="#00FF00" vlink="#006600">
<table border="0" cellpadding="0" cellspacing="0" width="621">
<!-- fwtable fwsrc="无标题" fwbase="right.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
  <tr>
   <td><img src="images/spacer.gif" width="5" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="15" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="5" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="2" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="38" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="55" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="82" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="96" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="87" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="115" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="65" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="30" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="5" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="15" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="6" height="1" border="0"></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0"></td>
  </tr>

  <tr>
   <td colspan="15" bgcolor="#dcf6ce"><img src="images/spacer.gif" width="621" height="5" border="0"></td>
   <td><img src="images/spacer.gif" width="1" height="5" border="0"></td>
  </tr>
  <tr>
   <td colspan="4" bgcolor="#dcf6ce"><img src="images/spacer.gif" width="27" height="19" border="0"></td>
   <td colspan="3"><img name="right_r2_c5" src="images/right_r2_c5.gif" width="175" height="19" border="0"></td>
   <td colspan="8" bgcolor="#dcf6ce"><div align="right">::::上传照片::::&nbsp;&nbsp;</div></td>
   <td><img src="images/spacer.gif" width="1" height="19" border="0"></td>
  </tr>
  <tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -