各位大虾:
有谁有类似qq空间批量上传图片工具代码?小弟急需...
或者如何实现一个选择对话框选上多个图片?谢了.

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>仿网易126网络硬盘上传 by littlelam</title>
    </head>
    <script>
    //css样式以及部分代码源自126
    var TotalFiles = 0;
    function AddFiles()
    {
        TotalFiles ++;
        var file=document.createElement("input"); 
        file.type = "file";
        file.id = "f"+ TotalFiles.toString();
        file.name = "files"+ TotalFiles.toString(); 
        file.hideFocus = true;
        file.size = 1;
        file.style.cssText = "cursor:pointer; width:1px; border:none; height:32px; padding:0px; margin:0px;position:absolute; opacity:0;filter:alpha(opacity=0);left:-32px !important;left:-5px;left/**/:-3px; font-size:20px;";
        file.onchange = function ()
        {
            for (var i=1;i<=TotalFiles;i++)
            {
                if ($("f"+i.toString())&&$("f"+i.toString())!=this)
                {
                    if ($("f"+i.toString()).value == this.value)
                    {
                        DelFile(this.id.replace("f",""));
                        AddFiles();
                        window.alert("已有相同文件,无须重复上传");
                        return;
                    }
                        
                }
                    
            }
            $("s"+TotalFiles.toString()).innerHTML = "<table class=oplist_filelist cellSpacing=0 cellPadding=0 width="100%" border=0><tr class=tr_file><td class=td_pathlist>&nbsp;" + $("f"+TotalFiles.toString()).value +  "</td><td class=td_operate noWrap><span onclick="DelFile('"+TotalFiles.toString()+"')" style="cursor:pointer;color:red;font-weight:bloder;">X&nbsp;移除</span></td></tr></table>";
            this.style.display = "none";
            AddFiles();
            CheckUploadDiv();
        };
        $("uploadInput").appendChild(file);
        var div=document.createElement("div"); 
        div.id = "s"+ TotalFiles.toString();
        $("uploadDiv").appendChild(div);}
    function DelFile(str)
    {
        $("uploadInput").removeChild($("f"+str));
        $("uploadDiv").removeChild($("s"+str));  
        CheckUploadDiv();
    }
    function CheckUploadDiv()
    {
        $("divNone").style.display = $("uploadDiv").innerHTML.indexOf("移除")==-1?"":"none";
    }
    function DelEmpty()
    {
        for (var i=1;i<=TotalFiles;i++)
        {
            if ($("f"+i.toString()))
            {
                if ($("f"+i.toString()).value == "")
                    $("uploadInput").removeChild($("f"+i.toString()));
            }
                
        }
    }
    function checkForm()
    {
        var HaveFile = false;
        for (var i=1;i<=TotalFiles;i++)
        {
            if ($("f"+i.toString()))
            {
                if ($("f"+i.toString()).value != "")
                {
                    HaveFile = true;
                    break;
                }
            }            
        }
        if (!HaveFile)
        {
            window.alert("点击“添加文件”按钮 添加要上传的文件");    
            return false;
        }    
        $("submitButton").disabled = true;
        DelEmpty();
        return true;
    }
    function $(id)
    {
        return document.getElementById(id);    
    }
    </script>
    <style>
    a.btn{background-image:url(http://mimg.163.com/netfolder/images/all_toolbar.gif);display:block; background-position:2px -32px; margin:6px 4px;float:left; border:1px solid #bebebe; cursor:pointer; position:relative;}
    .addbtn{height:32px;width:100px;}
    a.btn:hover{background-position:2px -64px; border:1px solid #d2d2d2; background-color:#FFFFEE;}
    </style>
    <body>
    <FORM METHOD="post" NAME="form1" ACTION="savetofile.aspx" ENCTYPE="multipart/form-data" onSubmit="return checkForm();">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="twp_all">
      
        <tr>
          <td><div class="oplist_op_af_inner" id="buttonDiv"><a href="javascript:AddFiles();" class="btn"><div id="uploadInput" class="addbtn"></div></a>          
            </div>
            </td>
        </tr>
        <tr>
          <td>
            <div class="twp_con_div2" id="filePanel">
              <table width="100%" border="0" cellspacing="0" cellpadding="0" class="oplist_filelist">
                <tr class="tbl_inner_title">
                  <td class="td_pathlist">文件路径</td>
                  <td nowrap class="td_operate">操作</td>
                </tr>
              </table>          
              <div id="uploadDiv"></div>
            </div>
           </td>
        </tr>
    <script>AddFiles();</script>  
      <tr>
        <td class="wp_bottom button_bar"><input name="submit" id="submitButton" type="submit" value="开始上传">
          &#160;
         </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    我copy下来,老是提示javascrip:AddFiles()有误,所以无法使用....
      

  3.   

    JS已没问题,但无法多选啊...一个控件可以选上各种图片...bmp/psd/jpg/jif....
      

  4.   

    我要的是一次多选啊,而不是一次次添加...不过还得谢谢littlelam ,因为这功能也是十发优秀的...
      

  5.   

    QQ是使用ActiveX控件实现的。以前写了一个ActiveX多文件上传插件,过段时间传给你。
      

  6.   

    谢谢....记得给我啊...
    我现在在做一个类似的功能,但asp.net 如何获得当前windows登陆账号...这样就不知那用户桌面了...
      

  7.   

    能不能也传给我啊,谢谢了啊
    [email protected]
      

  8.   

    can you help to send it to me.thanks.
    email:[email protected]
      

  9.   

    can you help to send it to me.thanks.
      

  10.   

    来的太晚了我也要哦。[email protected]   急呢```
      

  11.   

    给我也传个撒 QQ284820941  EMIAL:[email protected]
      

  12.   

    麻煩給我一份,急需,[email protected],萬分感謝。
      

  13.   

    麻煩給我一份,急需,[email protected],萬分感謝。
      

  14.   

    我也要  [email protected]
      

  15.   

    网上好像有一个Web图片上传控件。
    主界面图片列表添加图片编辑图片:提示信息:
      

  16.   

    你在网上搜一下,很多的。http://www.cnblogs.com/xproer/archive/2010/08/09/1796077.html
      

  17.   

    这个貌似是Xproer.ImageUploader。我之前接的一个单子也是用的这个控件。客户比较满意。主要是整合比较方便。
      

  18.   

    我也要啊  [email protected]  发个我吧·
      

  19.   

    我也要一个了 [email protected]
      

  20.   

    我也想要,求发货[email protected]
      

  21.   

    Xproer.ImageUploader:http://www.cnblogs.com/xproer/archive/2010/08/09/1796077.html
    主界面图片列表添加图片编辑图片:提示信息:整合代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Web图片批量上传控件演示页面</title>
    <script type="text/javascript" src="ImageUploader/ImageUploader.js" charset="utf-8"></script>
    </head>
    <body>
    <div><a href="asp.net/images.aspx">查看上传的图片</a></div>
    <div id="msg"></div>
    <script language="javascript" type="text/javascript">
    var imgUploader = new ImageUploader();
    imgUploader.Config["PostUrl"] = "http://localhost/php/upload.php"; window.onload = function()
    {
    imgUploader.Init();
    }
    </script>
    </body>
    </html>
    示例下载:
    CAB安装包
    ASP示例下载
    ASP.NET示例
    JSP示例
    PHP示例
      

  22.   

    你有这个控件吗
    请发给我一份 [email protected]