日期:2011-10-08  浏览次数:20403 次

 

  #*********************************************************

  #文件名称:

  inc_class.upload.php

  #Copyright (c)

  2007-2009 青春一度 all rights reserved.

  #最后更新: 2009-08-05

  #版本 : v 2.0.a

  #注:转发时请保留此声明信息,这段声明不并会影响你的速度!

  #如有修改请将修改后的文件以邮件形式发送给作者一份,谢谢!

  #

  #*********************************************************

  if(!defined('IN_PHPADLEYIU'))

  {

  exit('Access Denied');

  }

  /*

  //使用说明:

  //声明一个上传类

  include_once(ADLEYLIU_ROOT.'./inc_class.upload.php');

  $_YL_UPLOAD

  = array();

  $yl_uploadfile = new

  yl_upload_class();

  $_YL_UPLOAD['yl_filedata'] =

  'uploadFile';//表单名

  $_YL_UPLOAD['yl_directroy'] =

  'upload_files';//上传主目录

  $_YL_UPLOAD['file_urldirectroy'] = '/';//

  程序路径

  $_YL_UPLOAD['yl_settingsnew'] =

  ''.date('ym').'/'.date('d').'/'.substr(time(), 0,

  5).'';//上传子主目录

  $_YL_UPLOAD['yl_maxsize'] = 1048576;

  //这里以字节为单位(1024*2)*1024=2097152 就是 2M

  $_YL_UPLOAD['yl_sizeformat'] =

  'k'; //显示文件大小单位b字节,k千,m兆

  $_YL_UPLOAD['yl_arrext'] =

  array('gif','jpg','jpeg','png','bmp','rar','txt');//允许上传文件类型

  $_YL_UPLOAD['yl_ext'] = 0; //0原文件类型上传,1统一为存为jpg

  $_YL_UPLOAD['yl_prefix'] = ''.$uid.''.$yl_uploadfile -> yl_createrand(1,0).''.$cid.'';

  //在文件名前缀加上特殊字符 //$uid 会员ID $cid 分类ID

  $_YL_UPLOAD['yl_suffix'] = ''; //''.$yl_uploadfile -> yl_createrand(3,0).'';

  //在文件名后缀加上特殊字符

  $_YL_UPLOAD['thumbwidth'] = 100;

  //缩略图宽

  $_YL_UPLOAD['thumbheight'] = 100;

  //缩略图高

  $_YL_UPLOAD['maxthumbwidth'] = 500;

  //大图高

  $_YL_UPLOAD['maxthumbheight'] = 500;

  //大图宽

  //上传

  $yl_uploadfile -> yl_uploadfile();

  获取值:

  'yl_filename' => addslashes($_YL_UPLOAD['yl_filename']),原文件名

  'yl_attachment' => $_YL_UPLOAD['yl_attachment'],新文件名及路径

  'yl_filesize' => $_YL_UPLOAD['yl_filesize'] ,文件大小

  'yl_filetype' => $_YL_UPLOAD['yl_filetype'],文件类型

  'yl_isimage' => $_YL_UPLOAD['yl_isimage'],是否是图片

  'yl_isthumb' => $_YL_UPLOAD['yl_isthumb'],是否有小图片

  */

  class yl_upload_class

  {

  function __GET($property_name)

  {

  if(isset($this -> $property_name))

  {

  return $this -> $property_name;

  } else

  {

  return

  NULL;

  }

  }

  function __SET($property_name,

  $value) {

  $this -> $property_name =

  $value;

  }

  #*********************************************************

  #生成缩略图

  #*********************************************************

  function makethumb($srcfile) {

  global $_YL_UPLOAD;

  //判断文件是否存在

  if (!file_exists($srcfile))

  {

  return '';

  }

  $dstfile =

  $srcfile.'.small.jpg';

  $bigfile =

  $srcfile.'.big.jpg';

  //缩略图大小

  $tow =

  intval($_YL_UPLOAD['thumbwidth']);

  $toh =

  intval($_YL_UPLOAD['thumbheight']);

  if($tow < 60) $tow =<