+ -
当前位置:首页 → 问答吧 → 贡献一个AjaxUploader小程序

贡献一个AjaxUploader小程序

时间:2009-01-13

来源:互联网

[code]
/*
    ITEM       : AJAXUPLOADER
    Document   : Config
    Created on : 2009-01-15
    Author     : ERROR < error#live.cn >
    QQ         : 332133
    Vertion    : 0.1
    Demo       : http://error.i0750.com/ajaxuploader
    Download   : http://error.i0750.com/ajaxuploader/au01.rar
*/[/code]

来PHPCHINA时间也不短了,承蒙各位大大的指点,学了不少东西,却一直也没做出过什么贡献,现在就拿出一个自己做的程序,给有需要的同学参考,水平有限,尤其对于PHP5的对象还是刚开始接触,请多指教

主要功能就是Ajax+Uploader,简单的封装了一下,使用的时候配置一下变量就可以了
里面图片处理的部分用了小雨哥哥的图片处理类(略做0.01%的改进),不敢掠美,特此声明。

[code]
$_au['path'] = "./upload/";                 //存放图片路径
$_au['aTypes'] = array("jpg","gif","png");   //图片格式
$_au['pre_thumb'] = "_a_";                  //缩略图文件名前缀
$_au['pre_pic'] = "_b_";                    //图片名前缀
$_au['thumb_width'] = '100';                 //缩略图宽度
$_au['thumb_height'] = '100';                //缩略图高度
$_au['pic_width'] = "800";                  //上传后图片宽度
$_au['pic_height'] = "800";                 //上传后图片高度
$_au['zoomin'] = '1';                        //原图比设定尺寸小时是否进行放大
$_au['watermark'] = './images/wmlogo.png';   //水印图片路径
$_au['watermark_pos'] = '7';                 //加水印位置
$_au['watermark_trans'] = '50';              //水印透明度
$_au['maxPicNum'] = '5';                     //最大图片数量
$_au['maxPicSize'] = '1024000';              //允许上传的最大bytes
$_au_lightBox = 1;                         //是否使用lightBox效果
[/code]


在线演示:http://error.i0750.com/ajaxuploader

au.png (86.26 KB)

下载次数:275

2009-1-15 15:18

作者: error   发布时间: 2009-01-13

附加一点功能说明:

1、可以自定义图片存放的路径、图片最长边大小(按比例缩放)、缩略图大小等基本数据
2、可以自动给图片加水印,推荐使用PNG格式水印
3、目前图片输出质量是按最高质量输出的,不会因为加水印而降低图质
4、自带lightBox效果,但你可以关闭,避免跟你的程序里原有的lightBox冲突
5、图片上传前有预览,预览使用js模拟了简单的中央剪裁
6、上传过程中有进度条显示

程序包里的文件说明:
index.php        sample index
cl.ajaxuploader.php   ajaxuploader类
cfg.ajaxuploader.php   配置文件
ajaxuploader.js     javascript 函数库
ajaxuploader.css    css样式表
overlay.inc.php     包含文件
cl.watermark.php    小鱼哥哥的图片处理类

作者: error   发布时间: 2009-01-13

更新了。

v0.1

简化程序安装,自动载入image图像处理类
完善了AjaxUploader类的错误信息提醒机制
参数配置:增加水印透明度控制
修复IE浏览器缓存机制造成的AJAX出错
优化大量代码,重写部分类代码和Javascript函数库
修正所有已知错误
@2009.01.15

有网友报告不兼容FF,恩,我的电脑里只有IE
这个问题稍后再解决吧

作者: error   发布时间: 2009-01-13

[php]
<?php
header("Content-type: text/html;charset=utf-8");
/*
    ITEM       : AJAXUPLOADER
    Document   : Class
    Created on : 2009-01-15
    Author     : ERROR < error#live.cn >
    QQ         : 332133
    Vertion    : 0.1

    Demo       : http://error.i0750.com/ajaxuploader
    Download   : http://error.i0750.com/ajaxuploader/au01.rar
*/

class ajaxuploader {

    private $path;            //存放图片路径
    private $aTypes;          //图片格式数组
    private $pre_thumb;       //缩略图文件名前缀
    private $pre_pic;         //上传后的图片文件名前缀
    private $thumb_width;     //缩略图宽度
    private $thumb_height;    //缩略图高度
    private $pic_width;       //上传后图片宽度
    private $pic_height;      //上传后图片高度
    private $zoomin;          //原图小于设定宽度和高度时是否进行放大
    private $watermark;       //水印图片
    private $watermark_pos;   //加水印位置
    private $watermark_trans; //水印透明度
    private $maxPicNum;       //最大图片数量
    private $maxPicSize;      //允许上传的最大bytes
    private $pic_count;       //已上传文件数
    private $aErr;             //错误信息数组
    private $oImg;             //图片处理类对象

    public function __construct(){
        global $_au;
        $this->param($_au);
    }

    private function __get($property){
        if(isset($this->$property)){
            return($this->$property);
        }else{
            return(NULL);
        }
    }

    private function __set($property, $value){
        $this->$property = $value;
    }

    private function param($arr){
        if(is_array($arr)){
            foreach($arr as $key => $value){
                $this->$key = $value;
            }
        }

        $this->pic_count = 0;

        $this->aErr = array(
            0 => '路径('.$this->path.')不存在且自动建立失败,请手动建立!',
            1 => '上传的图片大小超过当前设定(Max:'.$this->maxPicSize.' bytes),请将文件缩小后再上传!',
            2 => '已达到当前限定的最大图片数量(Max:'.$this->maxPicNum.'),请删除部分图片后再上传!',
            3 => '图片格式错误!只允许上传 '.implode(",",$this->aTypes).' 格式的图片!',
            4 => '建立缩略图失败!',
            5 => '保存文件失败!',
            6 => '添加水印失败!',
            7 => '删除文件失败!',
            8 => 'image类文档不存在!'
        );

        //检测路径
        if(!$this->checkPath($this->path)){
            $this->reportErr(0);     //错误:目录不存在且建立目录失败!
        }

        //检测image类是否载入
        if($this->checkClass("image")){
            $this->oImg = new image();
        }else{
            $this->reportErr(8);
        }

        return $this;
    }

    //建立目录,此目录要有可读写权限
    private function checkPath($path){
        if(is_dir($path)){
            return true;
        }elseif(@mkdir($path)){
            return true;
        }

        return false;
    }

    //自动加载 Diqiye.Com 的 image 图片处理类
    private function checkClass($classname){
        if(class_exists($classname)){
            return true;
        }elseif(@include_once("cl.$classname.php")){
            return true;
        }

        return false;
    }

    //文件扩展名
    private function getFileExt($filename = ''){
        return strtolower(substr(strrchr($filename,"."),1));
    }

    //读取图片
    public function scanPic(){

        $filelist = @scandir($this->path);
        clearstatcache();

        //空目录
        if(!$filelist)  {
            return "!PIC";
        }

        foreach($filelist as $filename){
            if($this->pre_thumb == substr($filename,0,strlen($this->pre_thumb)) && in_array($this->getFileExt($filename),$this->aTypes)){
                $pic[] = $filename;
            }
        }

        //找到的图片数量
        $this->pic_count = count($pic);

        return $this->pic_count ? implode("|",$pic) : "!PIC" ;       //由"|"连接的文件名字符串 : 没有匹配的图片文件
    }

    //保存图片
    public function savePic(){

        $upPic = $_FILES['upfile']['tmp_name'];

        //错误:图片大小超过限制
        if($_FILES['upfile']['size'] > $this->maxPicSize){
            $this->reportErr(1);
            $this->reload();
            return false;
        }

        //错误:图片数量达到限制
        if($this->pic_count >= $this->maxPicNum){
            $this->reportErr(2);
            $this->reload();
            return false;
        }

        //错误:图片格式错误
        $ext = $this->getFileExt($_FILES['upfile']['name']);

        if(!in_array($ext,$this->aTypes)){
            $this->reportErr(3);
            $this->reload();
            return false;
        }

        //文件名的主体
        $main_filename  = date("Ymdhis",time());

        //缩略图
        $thumb_filename = $this->pre_thumb.$main_filename.".".$ext;

        //正式图片及路径
        $dstPic         = $this->path.$this->pre_pic.$main_filename.".".$ext;

        //*下面调用 Diqiye.Com 的图片处理类
        //$img = new image();
        // 中央剪裁缩略图
        if(!@$this->oImg->param($upPic)->thumb($this->path.$thumb_filename, $this->thumb_width,$this->thumb_height,1)){
            $this->reportErr(4);
            $this->reload();
            return false;
        }

        // 按设定大小生成图片
        if(!@$this->oImg->param($upPic)->thumb($dstPic, $this->pic_width, $this->pic_height,0,$this->zoomin)){
            $this->reportErr(5);
            $this->reload();
            return false;
        }

        // 添加水印
        if(!@$this->oImg->param($dstPic)->water($dstPic,$this->watermark,$this->watermark_pos,$this->watermark_trans)){
            $this->reportErr(6);
            $this->reload($thumb_filename);
            return false;
        }

        $this->pic_count++;
        $this->reload($thumb_filename);
    }

    //删除图片 * $pic 图片文件名
    public function removePic($pic){
        if(@unlink($this->path.$pic) && @unlink($this->path.str_replace($this->pre_thumb,$this->pre_pic,$pic))) {
            $this->pic_count--;
            return true;
        }else{
            $this->reportErr($this->aErr[6]);
            return "!F";        //删除失败
        }
    }

    //错误报告
    private function reportErr($errId){
        echo "<script type='text/javascript'>alert('".$this->aErr[$errId]."');</script></body></html>";
    }

    //前台重载
    private function reload($newpic = ''){
        echo "<script type='text/javascript'>window.parent.loadPic('$newpic');</script></body></html>";
    }
}
?>[/php]

作者: error   发布时间: 2009-01-13

[php]<?php
header("Content-type: text/html;charset=utf-8");
/*
    ITEM       : AJAXUPLOADER
    Document   : Class
    Created on : 2009-01-15
    Author     : ERROR < error#live.cn >
    QQ         : 332133
    Vertion    : 0.1

    Demo       : http://error.i0750.com/ajaxuploader
    Download   : http://error.i0750.com/ajaxuploader/au01.rar
*/

class ajaxuploader {

    private $path;            //存放图片路径
    private $aTypes;          //图片格式数组
    private $pre_thumb;       //缩略图文件名前缀
    private $pre_pic;         //上传后的图片文件名前缀
    private $thumb_width;     //缩略图宽度
    private $thumb_height;    //缩略图高度
    private $pic_width;       //上传后图片宽度
    private $pic_height;      //上传后图片高度
    private $zoomin;          //原图小于设定宽度和高度时是否进行放大
    private $watermark;       //水印图片
    private $watermark_pos;   //加水印位置
    private $watermark_trans; //水印透明度
    private $maxPicNum;       //最大图片数量
    private $maxPicSize;      //允许上传的最大bytes
    private $pic_count;       //已上传文件数
    private $aErr;             //错误信息数组
    private $oImg;             //图片处理类对象

    public function __construct(){
        global $_au;
        $this->param($_au);
    }

    private function __get($property){
        if(isset($this->$property)){
            return($this->$property);
        }else{
            return(NULL);
        }
    }

    private function __set($property, $value){
        $this->$property = $value;
    }

    private function param($arr){
        if(is_array($arr)){
            foreach($arr as $key => $value){
                $this->$key = $value;
            }
        }

        $this->pic_count = 0;

        $this->aErr = array(
            0 => '路径('.$this->path.')不存在且自动建立失败,请手动建立!',
            1 => '上传的图片大小超过当前设定(Max:'.$this->maxPicSize.' bytes),请将文件缩小后再上传!',
            2 => '已达到当前限定的最大图片数量(Max:'.$this->maxPicNum.'),请删除部分图片后再上传!',
            3 => '图片格式错误!只允许上传 '.implode(",",$this->aTypes).' 格式的图片!',
            4 => '建立缩略图失败!',
            5 => '保存文件失败!',
            6 => '添加水印失败!',
            7 => '删除文件失败!',
            8 => 'image类文档不存在!'
        );

        //检测路径
        if(!$this->checkPath($this->path)){
            $this->reportErr(0);     //错误:目录不存在且建立目录失败!
        }

        //检测image类是否载入
        if($this->checkClass("image")){
            $this->oImg = new image();
        }else{
            $this->reportErr(8);
        }

        return $this;
    }

    //建立目录,此目录要有可读写权限
    private function checkPath($path){
        if(is_dir($path)){
            return true;
        }elseif(@mkdir($path)){
            return true;
        }

        return false;
    }

    //自动加载 Diqiye.Com 的 image 图片处理类
    private function checkClass($classname){
        if(class_exists($classname)){
            return true;
        }elseif(@include_once("cl.$classname.php")){
            return true;
        }

        return false;
    }

    //文件扩展名
    private function getFileExt($filename = ''){
        return strtolower(substr(strrchr($filename,"."),1));
    }

    //读取图片
    public function scanPic(){

        $filelist = @scandir($this->path);
        clearstatcache();

        //空目录
        if(!$filelist)  {
            return "!PIC";
        }

        foreach($filelist as $filename){
            if($this->pre_thumb == substr($filename,0,strlen($this->pre_thumb)) && in_array($this->getFileExt($filename),$this->aTypes)){
                $pic[] = $filename;
            }
        }

        //找到的图片数量
        $this->pic_count = count($pic);

        return $this->pic_count ? implode("|",$pic) : "!PIC" ;       //由"|"连接的文件名字符串 : 没有匹配的图片文件
    }

    //保存图片
    public function savePic(){

        $upPic = $_FILES['upfile']['tmp_name'];

        //错误:图片大小超过限制
        if($_FILES['upfile']['size'] > $this->maxPicSize){
            $this->reportErr(1);
            $this->reload();
            return false;
        }

        //错误:图片数量达到限制
        if($this->pic_count >= $this->maxPicNum){
            $this->reportErr(2);
            $this->reload();
            return false;
        }

        //错误:图片格式错误
        $ext = $this->getFileExt($_FILES['upfile']['name']);

        if(!in_array($ext,$this->aTypes)){
            $this->reportErr(3);
            $this->reload();
            return false;
        }

        //文件名的主体
        $main_filename  = date("Ymdhis",time());

        //缩略图
        $thumb_filename = $this->pre_thumb.$main_filename.".".$ext;

        //正式图片及路径
        $dstPic         = $this->path.$this->pre_pic.$main_filename.".".$ext;

        //*下面调用 Diqiye.Com 的图片处理类
        //$img = new image();
        // 中央剪裁缩略图
        if(!@$this->oImg->param($upPic)->thumb($this->path.$thumb_filename, $this->thumb_width,$this->thumb_height,1)){
            $this->reportErr(4);
            $this->reload();
            return false;
        }

        // 按设定大小生成图片
        if(!@$this->oImg->param($upPic)->thumb($dstPic, $this->pic_width, $this->pic_height,0,$this->zoomin)){
            $this->reportErr(5);
            $this->reload();
            return false;
        }

        // 添加水印
        if(!@$this->oImg->param($dstPic)->water($dstPic,$this->watermark,$this->watermark_pos,$this->watermark_trans)){
            $this->reportErr(6);
            $this->reload($thumb_filename);
            return false;
        }

        $this->pic_count++;
        $this->reload($thumb_filename);
    }

    //删除图片 * $pic 图片文件名
    public function removePic($pic){
        if(@unlink($this->path.$pic) && @unlink($this->path.str_replace($this->pre_thumb,$this->pre_pic,$pic))) {
            $this->pic_count--;
            return true;
        }else{
            $this->reportErr($this->aErr[6]);
            return "!F";        //删除失败
        }
    }

    //错误报告
    private function reportErr($errId){
        echo "<script type='text/javascript'>alert('".$this->aErr[$errId]."');</script></body></html>";
    }

    //前台重载
    private function reload($newpic = ''){
        echo "<script type='text/javascript'>window.parent.loadPic('$newpic');</script></body></html>";
    }
}
?>[/php]

作者: error   发布时间: 2009-01-13

[php]/*
    ITEM       : AJAXUPLOADER
    Document   : Javascript 函数库
    Created on : 2009-01-12
    Author     : ERROR < error#live.cn >
    QQ         : 332133
    Vertion    : 0.1beta

    Demo       : http://error.i0750.com/ajaxuploader
    Download   : http://error.i0750.com/ajaxuploader/au01b.rar

*/
function $(id) {
    if(document.getElementById(id)){
        return document.getElementById(id);
    }else{
        alert("{ "+id+" } 未定义");
        return false;
    }
}

function removeObj(objlist){
    var aObj = objlist.split(",");
    for(i=0; i < aObj.length; i++){
        $(aObj).style.display = 'none';
    }
}

Array.prototype.in_array = function(e){
    for(i=0;i<this.length && this!=e;i++);
    return !(i==this.length);
}

/*
* 初始化AJAX
*/
function initAjax(){
        var ajax=false;
        try {
                ajax = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                        ajax = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                        ajax = false;
                }
        }
        if (!ajax && typeof XMLHttpRequest!='undefined') {
                ajax = new XMLHttpRequest();
        }
        return ajax;
}
/*
* LightBox 效果
*/
function lightBox(){
    var bgMark = $('bgMask');
    bgMark.style.top = '0px';
    bgMark.style.left = '0px';
    bgMark.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + 'px';
    bgMark.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + 'px';
        bgMark.innerHTML = '<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>';
    bgMark.style.display = 'block';

}
/*
* 弹出对话框
*/
function popWindow(nWidth,nHeight){
    var popWindow = $('popWindow');
    if(!nWidth) nWidth = 500;
    if(!nHeight) nHeight = 300;

    if(nWidth) popWindow.style.width = nWidth + 'px';
    if(nHeight) popWindow.style.height = nHeight + 'px';

        popWindow.style.top = (document.documentElement.clientHeight - nHeight)/2+"px";
        popWindow.style.left = (document.documentElement.clientWidth - nWidth)/2+"px";

    if(lightBoxEnabled) lightBox();
   
    popWindow.style.display = 'block';
}
/*
*显示图片管理对话框
*/
function showPicBox(){
    aPic = new Array(0);    //重新初始化图片数组

    //lightBox();

    var ajax = false;
    var url = "index.php?act=scanPic";
    ajax = initAjax();
    //alert(url);
    ajax.open("GET", url, true);
    ajax.send(null);
    ajax.onreadystatechange = function() {
        if (ajax.readyState == 4){
            if(ajax.status == 200) {
                //alert(ajax.responseText);
                if(ajax.responseText != '!PIC' ){
                    aPic = ajax.responseText.split('|');        //返回的图片名存入数组
                }
                loadPic();              //载入图片
                popWindow(550,250);
                        }else{
                              alert("发生错误: 连接服务器失败,请稍候再试!");
                   }
        }
          }
}
/*
* 上传新图片
*/
function savePic(){
    var upfile = $('upfile').value;

    if(!upfile){
        return false;       //没有选择文件
    }

    if(nPicNum >= nMaxPicNum){               //图片数超过限定
        alert("当前设置只允许上传 "+nMaxPicNum+" 张图片!");  
        return false;
    }

    var ext = upfile.substr(upfile.lastIndexOf('.')+1).toLowerCase();

    if(!aTypes.in_array(ext)){
        alert("文件类型错误,只能上传 "+aTypes.toString()+" 格式的图片!");
        return false;
    }

    $('btn_upload').disabled = true;
    $('progressBar_'+nPicNum).style.visibility = 'visible';
    $('upform').submit();
    $('upfile').disabled = true;
}
/*
* 上传预览
*/
function previewPic(){
    var img = new Image;
    img.src = $('upfile').value;
    if(!img.src)    return false;
   
    nPicNum = aPic.length;
    var pp = $('pic_'+nPicNum);
    pp.innerHTML = "";
    pp.className = 'sPicPreview';
    setTimeout(function(){
        if(img.width > img.height){
            var r = img.width/100;
            var p = 0 - Math.ceil((img.width - img.height)/2/r);
            pp.innerHTML = "<img src='"+img.src+"' height='100' style='position: relative;left:"+p+"px'>";
        }else{
            var r = img.height/100;
            var p = 0 - Math.ceil((img.height - img.width)/2/r);
            pp.innerHTML = "<img src='"+img.src+"' width='100' style='position: relative;top:"+p+"px'>";
        }
    },500);

    return true;
}
/*
* 载入图片
*/
function loadPic(newPic){
    var sStr = '';

    //新图片文件名追加入数组
    if(newPic){ nPicNum = aPic.push(newPic); }

    nPicNum = aPic.length;

    //载入图片
    for(i = 0; i < nMaxPicNum; i++){
        if(aPic){
            sStr += "<div id='pic_"+i+"' class='sPicThumb' style='background:url("+sPicPath+aPic+")'>";
            sStr += "<div class='btn_remove' onclick='removePic(\""+aPic+"\","+i+")'></div></div>";
        }else{
            sStr += "<div id='pic_"+i+"' class='sPicThumb'></div>";
        }
    }

    //设置进度条
    for(i = 0; i < nMaxPicNum; i++){
        sStr +="<div id='progressBar_"+i+"' class='progressBar'></div>";
    }

    $('picBox').innerHTML = sStr;

    if(nPicNum < nMaxPicNum){
        $('btn_upload').disabled = false;
        $('upfile').disabled = false;
    }else{
        $('btn_upload').disabled = true;
        $('upfile').disabled = true;
    }
    return true;
}
/*
* 删除图片
*/
function removePic(sPic,picId){
    //显示进度条
    $('progressBar_'+picId).style.visibility = 'visible';

    var ajax = false;
    var url = "index.php?act=removePic&pic="+sPic;

    ajax = initAjax();
    ajax.open("GET", url, true);
    ajax.send(null);

    ajax.onreadystatechange = function() {
        if (ajax.readyState == 4){
            if(ajax.status == 200) {
                //alert(ajax.responseText);
                if(ajax.responseText == '!F'){           //删除失败
                    alert("删除失败");
                }else{
                    //aPic = array_delete(aPic,picId);
                    aPic.splice(picId,1);
                    loadPic();
                }
                        }else{
                              loadingBox("发生错误: 连接服务器失败,请稍候再试!");
                   }
        }
          }
}[/php]

作者: error   发布时间: 2009-01-13

[php]/*
    ITEM       : AJAXUPLOADER
    Document   : style
    Created on : 2009-01-12
    Author     : ERROR < error#live.cn >
    QQ         : 332133
    Vertion    : 0.1beta

    Demo       : http://error.i0750.com/ajaxuploader
    Download   : http://error.i0750.com/ajaxuploader/au01b.rar
*/

/* global */
root {
    display: block;
}
*{
    color:#333;
    font-size:12px;
    font-family: Verdana,Arial, Helvetica, sans-serif;
    line-height:15px;
    margin:0;
    padding:0;
}
img {
    border: 0;
}
body{
    margin:20px;
}
h1{
    font-size:20px;
    line-height:40px;
}
.clear {
    clear:both;
}

/* form & button */
button {
    width:auto;
    height:20px;
        border: #ccc 1px solid;
        color: #333;
        FONT-FAMILY: "Tahoma", "MS Shell Dlg";
}
#upfile {
    width:300px;
    height:20px;
        border: #ccc 1px solid;
        color: #333;
        FONT-FAMILY: "Tahoma", "MS Shell Dlg";
    margin:0px 5px;;
}
#btn_upload {
    width:80px;
    height:20px;
        border: #ccc 1px solid;
        color: #333;
        FONT-FAMILY: "Tahoma", "MS Shell Dlg";
    background:url(images/btn_upload.gif) 8px no-repeat;
}
#btn_ok{
    float:right;
    width:80px;
    height:20px;
        border: #ccc 1px solid;
        color: #333;
    margin:20px 20px;
        FONT-FAMILY: "Tahoma", "MS Shell Dlg";
    background:url(images/btn_ok.gif) 8px no-repeat;
}
.btn_remove{
    float:right;
    margin:2px 1px;
    width:12px;
    height:12px;
    border:1px #ccc solid;
    background:url(images/btn_remove.gif) no-repeat -1px -1px;
    background-color:#fff;
    overflow:hidden;
    cursor:pointer;
}

/* popwindow */
#popWindow{
    display:none;
        position:absolute;
    z-index:100;
    border:5px #ccc solid;
    background-color:#fff;
}
#pop_bar{
    background-color:#669;
    border:1px #669 solid;
    height:25px;
}
#pop_title{
    float:left;
        color: #FFFFFF;
        font-family:Arial, Helvetica, sans-serif;
        font-size: 12px;
    padding-top:7px;
    padding-left:5px;
}
#pop_close {
    float:right;
    margin-right:5px;
    margin-top:5px;
    width:15px;
    height:15px;
    background:url(images/btn_close.gif) no-repeat top;
    cursor:pointer;
}
#picBox{
    background-color:#ddd;
    width:100%;
    height:130px;
    overflow:hidden;
}
.sPicThumb{
    float:left;
    margin:8px 4px 0px 4px;
    width:100px;
    height:100px;
    background-color:#eee;
    background-image:none;
    background-repeat:no-repeat;
}
.sPicPreview{
    position: relative;
    float:left;
    margin:8px 4px 0px 4px;
    width:100px;
    height:100px;
    overflow:hidden;
    background-color:#fff;
    background-image: url(images/loading.gif);
    background-position:50% 50%;
    background-repeat:no-repeat;
    filter:Alpha(opacity=30);
}
.progressBar {
    float:left;
    visibility: hidden;
    background:url(images/progressBar.gif) no-repeat;
    margin:0px 4px 4px 4px;
    width:100px;
    height:9px;
}
#formBox{
    margin:5px 10px;
}
#tipsBox{
    float:left;
    margin:5px 10px;
}

/* other */
#bgMask {
        position:absolute;
        background-color:#000;
        filter:Alpha(opacity=50);
        display:none;
        z-index:50;
}[/php]

作者: error   发布时间: 2009-01-13

不错 支持啊

作者: joj_79   发布时间: 2009-01-14

看起来很漂亮都!

作者: ieiavj   发布时间: 2009-01-14

我觉得 图片后缀判断 放在PHP文件中判断更安全! 放在JS里面用户可以修改后本地提交 这样不是能绕过文件判断 直接传 .PHP的文件了?

作者: phpeval   发布时间: 2009-01-15

原帖由 phpeval 于 2009-1-15 14:07 发表
我觉得 图片后缀判断 放在PHP文件中判断更安全! 放在JS里面用户可以修改后本地提交 这样不是能绕过文件判断 直接传 .PHP的文件了?
说的很是。

今天上传了一个新版本,在PHP里也进行一次表单校验。

另外还有许多修改。

请到原网址测试。

作者: error   发布时间: 2009-01-15

看着挺NB!

作者: sinopf   发布时间: 2009-01-15

呵呵 强烈 支持中

作者: suruijie123   发布时间: 2009-01-19

作者: yinhe418   发布时间: 2009-01-19

不错,顶一下

作者: 樰影   发布时间: 2009-01-20

下载下来研究下....

作者: 艾克   发布时间: 2009-01-20

IE7下,Firefox下,预览图功能都是不能用的。
基于ie的其他浏览器到是可以,比如世界之窗。

作者: Do1Win2   发布时间: 2009-01-20

不错支持。
下来看看

作者: fejay   发布时间: 2009-01-20

多谢楼主分享,代码不错,图片上的妞也不错。

作者: raylzw   发布时间: 2009-01-23

牛,怎么总有这么多牛X的人呢?

作者: go_tit   发布时间: 2009-01-24

图片不错!很漂亮! 谢谢楼主

作者: aoyoo   发布时间: 2009-01-28

收藏了!嘿嘿!谢谢

作者: aoyoo   发布时间: 2009-02-02

作者: ws00377531   发布时间: 2009-02-02

要鼓励原创。

作者: luzhou   发布时间: 2009-02-03

听楼上的哥们说了很漂亮,存起来试试

作者: kwlong   发布时间: 2009-02-14

收藏了。谢谢

作者: wxqaz   发布时间: 2009-03-07

...........................

作者: delinking   发布时间: 2009-03-15

看样子很牛B

!!!

先下了,试试看。。。

作者: cone   发布时间: 2009-03-15

不错的实例

作者: kuake   发布时间: 2009-03-30

本帖最后由 max_qu 于 2009-7-31 09:47 编辑

顶!!学习了!!

作者: max_qu   发布时间: 2009-07-31

美女的诱惑

作者: simore   发布时间: 2009-08-02

支持一下

作者: sychen   发布时间: 2009-08-03

应该是使用了iframe来上传的吧?ajax可以支持文件上传么?

作者: sentrychen   发布时间: 2009-08-03

哇塞,楼主强人啊

作者: 泥小鬼   发布时间: 2009-08-06

踩一脚再说

作者: z0800   发布时间: 2009-08-06

效果不错,收下!!

作者: kora   发布时间: 2009-08-19

在火狐下面无法上传文件

作者: jiedushi   发布时间: 2009-08-21

好东西

作者: Kevin-Lau   发布时间: 2009-11-17

学习....

作者: zmjsg   发布时间: 2009-11-17

是的,还有设置图片目录为不可执行就更安全一些。

作者: mailangel123   发布时间: 2009-11-18