站内搜索
分类列表
本类阅读排行
本类推荐文章
- 配置整合Win+Apache+PHP+MySQL+Tc...
- 动态网页制作PHP常用的正则表达式
- PHP实例:上传多个图片并校验的代...
- PHP5中新增加的日期(date)函数的常...
- PHP实例:实现给上传图片加水印图案
- PHP 开发中的中文编码问题
- 用PHP程序直接调用文本文件内容实...
- PHP初学者:配置Apache服务器并且...
- 详细学习PHP中对文件和目录的操作...
- 确保PHP安全,不能违反的四条安全...
- 怎样在PHP 中运用 SimpleXML 处理...
- PHP5.2+APACHE2.2+BugFree1.0的安...
- PHP正式进入IIS微软与Zend携手推动...
- PHP5中PDO的简单使用
- Web服务器IIS6的PHP最佳配置方法
广告
文件上传——终结者Ⅰ
作者: 来源: 点击: 日期:2007-6-15 0:35:06
PHP代码:--------------------------------------------------------------------------------
<?
/*
------------------------------------------------------------------------------------
类名:Lwguploadandquery
说明:sql语句执行和文件上传类,是Lwgupload类的子类
作者:龙卫国
网络user:lwg888
邮箱:lwg888@163.com
使用、修改、传播请保留作者信息
------------------------------------------------------------------------------------
*/
require_once(dirname(__FILE__)."/Lwgdb.inc.php");//数据库连接与查询类
require_once(dirname(__FILE__)."/Lwgupload.inc.php");//父类
class Lwguploadandquery extends Lwgupload{
var $sql;//sql语句
var $url;//文件上传成功后转向的url
//重要提示:sql语句写法:
//$sql=sprintf("update test1 set name='%s', image1='%s', image2='%s' where id='%d'",$_POST['name'],"image1_name","image2_name",$_POST['id']);
//"image1_name","image2_name"中,image1和image2是文件域的name或id,后面加了"_name"后缀,便于下面找到它并修改它
function Lwguploadandquery($sql="",$uploadfield="",$url="",$uploadpath="",$maxsize="",$ftype="all"){
$this->sql=$sql;
$this->url=$url;
$this->Lwgupload($uploadfield,$uploadpath,$maxsize,$ftype);
}
function run(){
if (empty($this->sql))return $this->output("没有可执行的SQL语句。");
if (!is_array($this->uploadfield))$this->uploadfield=array($this->uploadfield);//如果不为数组改为数组,便于后面代码的简化
if (!is_array($this->maxsize))$this->maxsize=array($this->maxsize);//同上
if (!is_array($this->ftype))$this->ftype=array($this->ftype);//同上
$totaluploadfield=count($this->uploadfield);
for ($i=0;$i<$totaluploadfield;$i++){
$uploadfile=$_FILES[$this->uploadfield[$i]]['tmp_name'];
$file_name=$_FILES[$this->uploadfield[$i]]['name'];
$file_old=$_POST[$this->uploadfield[$i].'_old'];//用在更新中,表示上传文件所对应的原有文件
$file_del=$_POST[$this->uploadfield[$i].'_del'];//原有文件是否标记为删除
if ($uploadfile!=""&&$file_name!=""){
//表示需要上传,即文件域里填入了任何字符
$uploadfield[]=$this->uploadfield[$i];
文件上传——终结者Ⅰ 评论
