/**
* bkJia.com - 个人感觉非常简单,只要有点PHP基础滴人都应该能看懂~~
* Apache2 + PHP5.0
* Version:1.0
* 同时感谢bkJia所有的兄弟们
* ————————————————————————————————— Example —
* test.php @ 处理表单文件名
*
*
* include("upload.php"); # 加入类文件
* $f_upload = new upload_other; # 创建对象
* $f_upload->set_file_type($_FILES[src][type]); # 获得文件类型
* $f_upload->set_file_name($_FILES[src][name]); # 获得文件名称
* $f_upload->set_file_size($_FILES[src][size]); # 获得文件尺寸
* $f_upload->set_upfile($_FILES[src][tmp_name]); # 服务端储存的临时文件名
* $f_upload->set_size(100); # 设置最大上传KB数
* $f_upload->set_base_directory("uploadImages"); # 文件存储根目录名称
* $f_upload->set_url("up.php"); # 文件上传成功后跳转的文件
* $f_upload->save(); # 保存文件
*
* ?>
* —————————————————————————————————— End —
*
* 偶没有在类里做有无文件的验证,大家可以在前台搞定~~
*
* —————————————————————————— Form —
* upload.htm @ 表单文件名
*
*
*
*
*
*
*
*
*
*
* ———————————————————————————— End —
*
* 上面的两个文件可根据自己的需要决定合并或不合并~~如果在使用中有任何问题可以跟偶联系~~^_^
*
**/
/**文件上传类**/
class upload_file
{
/**声明**/
var $upfile_type,$upfile_size,$upfile_name,$upfile;
var $d_alt,$extention_list,$tmp,$arri;
var $datetime,$date;
var $filestr,$size,$ext,$check;
var $flash_directory,$extention,$file_path,$base_directory;
var $url; //文件上传成功后跳转路径;
function upload_file()
{
/**构造函数**/
$this->set_url("index.php"); //初始化上传成功后跳转路径;
$this->set_extention(); //初始化扩展名列表;
$this->set_size(50); //初始化上传文件KB限制;
$this->set_date(); //设置目录名称;
$this->set_datetime(); //设置文件名称前缀;
$this->set_base_directory("attachmentFile"); //初始化文件上传根目录名,可修改!;
}
/**文件类型**/
function set_file_type($upfile_type)
{
$this->upfile_type = $upfile_type; //取得文件类型;
}
/**获得文件名**/
function set_file_name($upfile_name)
{
$this->upfile_name = $upfile_name; //取得文件名称;
}
/**获得文件**/
function set_upfile($upfile)
{
$this->upfile = $upfile; //取得文件在服务端储存的临时文件名;
}
/**获得文件大小**/
function set_file_size($upfile_size)
{
$this->upfile_size = $upfile_size; //取得文件尺寸;
}
/**设置文件上传成功后跳转路径**/
function set_url($url)
{
$this->url = $url; //设置成功上传文件后的跳转路径;
}
/**获得文件扩展名**/
function get_extention()
{
$this->extention = preg_replace(/.*.(.*[^.].*)*/iU,\1,$this->upfile_name); //取得文件扩展名;
}
/**设置文件名称**/
function set_datetime()
{
$this->datetime = date("YmdHis"); //按时间生成文件名;
}
/**设置目录名称**/
function set_date()
{
$this->date = date("Y-m-d"); //按日期生成目录名称;
}
/**初始化允许上传文件类型**/
function set_extention()
{
$this->extention_list = "doc|xls|ppt|avi|txt|gif|jpg|jpeg|bmp|png"; //默认允许上传的扩展名称;
}
/**设置最大上传KB限制**/
function set_size($size)
{
$this->size = $size; //设置最大允许上传的文件大小;
}
/**初始化文件存储根目录**/
function set_base_directory($directory)
{
&n

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use