php给上传图片 以当前日期时间为水印请问各位高手如何实现

解决方案 »

  1.   

    ImageTTFText()用这个函数,自己查!
      

  2.   

    百了个度
    “php 水印”
    http://www.baidu.com/s?wd=php+%CB%AE%D3%A1&rsv_bp=0&rsv_spt=3&inputT=4303
    源码大堆
      

  3.   

    文字水印吧,那直接用date("Y-m-d",$_SERVER['request_time'])不行吗
      

  4.   


    这个参数我也调用过啦也不知是我调用错误还是怎么回事直接显示date("Y-m-d",$_SERVER['request_time'])
      

  5.   

    PHP图片加水印的代码示例:1.//上传文件类型列表     
    2.$uptypes=array(     
    3.'image/jpg',     
    4.'image/jpeg',     
    5.'image/png',     
    6.'image/pjpeg',     
    7.'image/gif',     
    8.'image/bmp',     
    9.'image/x-png'     
    10.);     
    11.$max_file_size=2000000; //上传文件大小限制, 单位BYTE     
    12.$destination_folder="uploadimg/"; //上传文件路径     
    13.$water=1; //是否附加水印(1为加水印,其他为不加水印);     
    14.$watertype=1; //水印类型(1为文字,2为图片)     
    15.$waterposition=1; //水印位置(1为左下角,2为右下角  
    16.,3为左上角,4为右上角,5为居中);     
    17.$waterstring="< A href="http://www.xplore.cn/"> 
    18.http://www.xplore.cn/< /A>"; //水印字符串     
    19.$waterimg="xplore.gif"; //水印图片     
    20.$imgpreview=1; //是否生成预览图(1为生成,其他为不生成);     
    21.$imgpreviewsize=1/2; //缩略图比例     
    22.?>     
    23.< html>     
    24.< head>     
    25.< title>ZwelL图片上传程序</title>     
    26.< style type="text/css">     
    27.<!--     
    28.body     
    29.{     
    30.font-size: 9pt;     
    31.}     
    32.input     
    33.{     
    34.background-color: #66CCFF;     
    35.border: 1px inset #CCCCCC;     
    36.}     
    37.-->     
    38.< /style>     
    39.< /head>     
    40.< body>     
    41.< form enctype="multipart/form-data"   
    42.method="post" name="upform">     
    43.上传文件:     
    44.<input name="upfile" type="file">     
    45.< input type="submit" value="上传">< br>     
    46.允许上传的文件类型为:<?=implode(', ',$uptypes)?>     
    47.< /form>     
    48.< ?php     
    49.if ($_SERVER['REQUEST_METHOD'] == 'POST')     
    50.{     
    51.if (!is_uploaded_file($_FILES["upfile"]  
    52.[tmp_name]))     
    53.//是否存在文件     
    54.{     
    55.echo "图片不存在!";     
    56.exit;     
    57.}     
    58.$file = $_FILES["upfile"];     
    59.if($max_file_size < $file["size"])     
    60.//检查文件大小     
    61.{     
    62.echo "文件太大!";     
    63.exit;     
    64.}     
    65.if(!in_array($file["type"], $uptypes))     
    66.//检查文件类型     
    67.{     
    68.echo "文件类型不符!".$file["type"];     
    69.exit;     
    70.}     
    71.if(!file_exists($destination_folder))     
    72.{     
    73.mkdir($destination_folder);     
    74.}     
    75.$filename=$file["tmp_name"];     
    76.$image_size = getimagesize($filename);     
    77.$pinfo=pathinfo($file["name"]);     
    78.$ftype=$pinfo['extension'];     
    79.$destination = $destination_folder.  
    80.time().".".$ftype;     
    81.if (file_exists($destination) &&  
    82. $overwrite != true)     
    83.{     
    84.echo "同名文件已经存在了";     
    85.exit;     
    86.}     
    87.if(!move_uploaded_file ($filename,  
    88. $destination))     
    89.{     
    90.echo "移动文件出错";     
    91.exit;     
    92.}     
    93.$pinfo=pathinfo($destination);     
    94.$fname=$pinfo[basename];     
    95.echo " <font color=red>已经成功上传  
    96.< /font><br>文件名:     
    97.< font color=blue>".$destination_folder.  
    98.$fname."< /font>< br>";     
    99.echo " 宽度:".$image_size[0];     
    100.echo " 长度:".$image_size[1];     
    101.echo "<br> 大小:".$file["size"]." bytes";     
    102.if($water==1)     
    103.{     
    104.$iinfo=getimagesize($destination,$iinfo);     
    105.$nimage=imagecreatetruecolor($image_size[0]  
    106.,$image_size[1]);     
    107.$white=imagecolorallocate($nimage,255,255,255);     
    108.$black=imagecolorallocate($nimage,0,0,0);     
    109.$red=imagecolorallocate($nimage,255,0,0);     
    110.imagefill($nimage,0,0,$white);     
    111.switch ($iinfo[2])     
    112.{     
    113.case 1:     
    114.$simage =imagecreatefromgif($destination);     
    115.break;     
    116.case 2:     
    117.$simage =imagecreatefromjpeg($destination);     
    118.break;     
    119.case 3:     
    120.$simage =imagecreatefrompng($destination);     
    121.break;     
    122.case 6:     
    123.$simage =imagecreatefromwbmp($destination);     
    124.break;     
    125.default:     
    126.die("不支持的文件类型");     
    127.exit;     
    128.}     
    129.imagecopy($nimage,$simage,0,0,0,0,  
    130.$image_size[0],$image_size[1]);     
    131.imagefilledrectangle($nimage,1,  
    132.$image_size[1]-15,80,$image_size[1],$white);     
    133.switch($watertype)     
    134.{     
    135.case 1: //加水印字符串是在是太多了,复制不过来,你去看看:http://www.phpnewer.com/index.php/Ymgx/detail/id/39