您好,欢迎访问一九零五行业门户网

tp完美整合多图片上传

tp完美整合多图片上传,网上找了很多控件均不能达到自己的要求,最后自己参考官方的例子结合自己对tp的不多认识,整合出来了适合自己用的,最近忙着项目,改天整理好了,单独分离出来上传分享,尽请期待哦; (暂时先把没改过的实例包发上来吧!有需要的朋友可以拿去参考)
更多技术文章请移步
http://www.dahuzhi.com
以下是部分代码:
');//在页面上显示文件相对路径
}
    });
});
//删除文件
function  del_img(whichsong)
{
    //盒子对象
    var info = document.getelementbyid('info');
    //当前图片对象
    var zi = whichsong.parentelement;
    //图片名称
    var path = zi.firstchild.name
    //产生对象
    var ajax=new xmlhttprequest;
    //生成事件处理器
    ajax.onreadystatechange=function(){
        if (ajax.readystate==4) {             //判断请求状态为4完成的时候
            if (ajax.status==200) {         //判断服务器的http状态码等于200
                //alert(ajax.responsetext); //弹出服务器的响应
                if(ajax.responsetext)
                {
                    //删除当前
                    info.removechild(zi);
                }
            }
        }
    }
    //打开链接
    ajax.open('post','/index.php/article/img');
    //设置http传输
    ajax.setrequestheader('content-type', 'application/x-www-form-urlencoded');
    //发送
    ajax.send('action=del_img&path=' + path);
}
内容列表
            内容管理/
            图片发布
图片编辑图片发布
editadd/>
/>
                    />
                    />
相片:
上传
                                        取消上传
                                        提示:只能上传
(jpg,gif,bmp)
格式图片
//多文件上传
    function upload() 
    {
        import(org.net.image3);
        if (!empty($_files)) 
        {
            //获取文件名
            $tempfile         = $_files['filedata']['tmp_name'];
            //保存路径
            $targetpath     = app_path . 'public/uploads/';
            //新图片名
            $new_file_name     = new_name( $_files['filedata']['name']);
            //图片网站路径
            $targetfile     = $targetpath . $new_file_name;
//判断是否文件夹存在
            if(!is_dir($targetpath))
                mkdir($targetpath, 0777, true);
//防止中文文件名乱码
            move_uploaded_file($tempfile,iconv('utf-8','gbk', $targetfile));
//水印
            $water = 'water.gif';
            $img   = new image3();
            $img->param($targetfile)->water($targetfile,$water,9);
            //ajax返回图片名称
            echo get_relative_path($new_file_name);
        }
    }
//图片模块
    public function img()
    {
        $c = d('class');
        $a = d('article');
        if($_post['action'] == 'add')
        {
            //判断是否有上传多文件
            if($_post['imgs'])
            {
                $_post['img'] = '';
                foreach ($_post['imgs'] as $v)
                {
                    $_post['img'] .= $v . ',';
                }
            }
//加载上传类
            $file = static::get_file(2097152);
            //判断是否上传文件
            $_post['simg']    = ($file) ? $file : '' ;
            $_post['addtime'] = exec_time();
            //dump($_post);die();
            //过滤数据并添加
            $a->create();
            if($a->add())
                static::success('添加成功', 3000, 1, 0);
        }
//获取所有分类信息
        $data = $c->order('nos asc')->select();
        //格式化无线分类
        $data = static::get_class($data);
        $this->assign('data', $data);
        //时间输出
        $this->assign('time', date('y-m-d', time()));
        $this->display();
    } uploadify_v1.0.rar ( 62.44 kb 下载:882 次 )
ad:真正免费,域名+虚机+企业邮箱=0元
其它类似信息

推荐信息