易截截图软件、单文件、免安装、纯绿色、仅160KB

php 图片上传类代码

<?
//http://www.jb51.net
class upLoad{
public $length; //限定文件大小
public $file; //判断此类是用于图片上传还是文件上传
public $fileName; //文件名
public $fileTemp; //上传临时文件
public $fileSize; //上传文件大小
public $error; //上传文件是否有错,php4没有
public $fileType; //上传文件类型
public $directory; //
public $maxLen;
public $errormsg;
function __construct($length,$file=true,$directory)
{
$this->maxLen=$length;
$this->length=$length*1024;
$this->file=$file; //true为一般文件,false为图片的判断
$this->directory=$directory;
}
public function upLoadFile($fileField)
{
$this->fileName=$fileField['name'];
$this->fileTemp=$fileField['tmp_name'];
$this->error=$fileField['error'];
$this->fileType=$fileField['type'];
$this->fileSize=$fileField['size'];
$pathSign = DIRECTORY_SEPARATOR; // /
if($this->file) //一般文件上传
{
$path = $this->_isCreatedDir($this->directory);//取得路径
if($path)//http://www.jb51.net
{
$createFileType = $this->_getFileType($this->fileName);//设置文件类别
$createFileName=uniqid(rand()); //随机产生文件名
$thisDir=$this->directory.$pathSign.$createFileName.".".$createFileType;
if(@move_uploaded_file($this->fileTemp,$thisDir)) //把临时文件移动到规定的路径下
{
return $thisDir;
}
}
}else{ //图片上传
$path = $this->_isCreatedDir($this->directory);//取得路径
if($path)//路径存在//http://www.jb51.net
{
$createFileType = $this->_getFileType($this->fileName);//设置文件类别
$createFileName=uniqid(rand());
return
@move_uploaded_file($this->fileTemp,$this->directory.$pathSign.$createFileName.".".$createFileType)
? true : false;
}
}
}
public function _isBig($length,$fsize) //返回文件是否超过规定大小
{
return $fsize>$length ? true : false;
}
public function _getFileType($fileName) //获得文件的后缀
{
return end(explode(".",$fileName));
}
publi


相关文档:

如何用C 编写PHP扩展

PHP取得成功的一个主要原因之一是她拥有大量的可用扩展。web开发者无论有何种需求,这种需求最有可能在PHP发行包里找到。PHP发行包包括支持各种数据库,图形文件格式,压缩,XML技术扩展在内的许多扩展。
  扩展API的引入使PHP取得了巨大的进展,扩展API机制使PHP开发社区很容易的开发出几十种扩展。。扩展主要的思想是 ......

PHP函数ereg与preg的区别

      1、ereg里面是不需要也不能使用分隔符和修饰符的,所以ereg的功能比preg要弱上不少。
  2、关于".":点在正则里面一般是除了换行符以外的全部字符,但是在ereg里面的"."是任意字符,即包括换行符!如果在preg里面希望"."
能够包括换行符,可以在修饰符中 ......

Redhat下 Apache, php, mysql的默认安装路径

apache:
如果采用RPM包安装,安装路径应在 /etc/httpd目录下
apache配置文件:/etc/httpd/conf/httpd.conf
Apache模块路径:/usr/sbin/apachectl
web目录:/var/www/html
如果采用源代码安装,一般默认安装在/usr/local/apache2目录下
php:
如果采用RPM包安装,安装路径应在 /etc/目录下
php的配置文件:/etc/php.ini ......

【待修改】表单验证之PHP代码框架

  我在上一篇文章中讲到使用javascript做集成表单验证的方法,对于客户端验证已经足够,但好的表单验证应同时在客户端和服务器端进行——这正是写本文的目的。
    如果采用一般的验证方法应该怎样写呢?
    if ($_POST['some'] 不满足 condition) {
   & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号