喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

$5.95 Web Hosting     

上一主题 下一主题
     
标题: [问题] 有没有JS实现多个文件上传的代码?  
 
tongj
注册会员
Rank: 2
初级会员


UID 62888
精华 0
积分 104
帖子 67
金钱 104 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-1-2
状态 离线
[广告]: 代充Paypal帐号美元
有没有JS实现多个文件上传的代码?

我想实现像QQ邮箱里面,发邮件时添加附件时的那种多个文件上传的效果

我试着分离出来了它的代码,可惜只能在单页面里面用,在IFRAME里面就不行了

不知道哪位大哥大姐有现成的代码?


 附件: 您所在的用户组无法下载或查看附件



爱资讯92jijin.com
2008-5-5 01:07 PM#1
查看资料  访问主页  Blog  发短消息  顶部
 
sanders_yao
版主
Rank: 7Rank: 7Rank: 7
or2 =333


UID 30286
精华 0
积分 2573
帖子 4778
金钱 2570 喜悦币
威望 0
人脉 3
阅读权限 100
注册 2004-7-23
来自 北京 菜户营
状态 离线
[广告]: 代充Paypal帐号美元
如果不刷新上传一般也都是使用iframe的吧



最近写的一些代码都会在以下地址发布,有兴趣的来批:
http://www.phpx.com/happy/thread-131368-1-1.html
2008-5-5 03:46 PM#2
查看资料  Blog  发短消息  顶部
 
tongj
注册会员
Rank: 2
初级会员


UID 62888
精华 0
积分 104
帖子 67
金钱 104 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-1-2
状态 离线
[推荐阅读] hoyong网店系统1.0发布拉
用JAVASCRIPT添加INPUT就行了的
我又自己写了一个程序,添加INPUT可以实现.但删除的时候不能完全对应

<?php
<HTML
<
HEAD
<
script
    var 
file_to=0;
    function 
add_inp(){ 
        
newInp document.createElement("input");
        
newInp.setAttribute("id","file_"+file_to);
        
newInp.setAttribute("type","file");
        
newInp.setAttribute("name","upfile[]");
        
div1.appendChild(newInp);
        
newInp document.createElement("<input onclick=del_inp("+file_to+")>");
        
newInp.setAttribute("id","file_del_"+file_to);
        
newInp.setAttribute("type","button");
        
newInp.setAttribute("value","删除");
        
div1.appendChild(newInp); 
        
newInp.setAttribute("id","file_br_"+file_to); 
        
newInp document.createElement("br"); 
        
div1.appendChild(newInp); 
        
file_to++;
    } 
    function 
del_inp(file_id){ 
        
file_id+=2;
        
file_to-=3;
        
div1.removeChild(div1.childNodes[file_id]); 
        
file_id--; 
        
div1.removeChild(div1.childNodes[file_id]);
        
file_id--; 
        
div1.removeChild(div1.childNodes[file_id]); 
    }
</script> 

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD> 
<BODY> 
<FORM METHOD="post" ENCTYPE="multipart/form-data" name=f1> 
<div id=div1> 
</div> 
<INPUT TYPE="button" VALUE="增加上传" onclick=add_inp()> 
<INPUT TYPE="button" VALUE="减少上传" onclick=del_inp()><br> 
<INPUT TYPE="submit" VALUE="提 交" NAME="Submit"> 
</FORM> 
</BODY>
?>




爱资讯92jijin.com
2008-5-5 03:58 PM#3
查看资料  访问主页  Blog  发短消息  顶部
 
tongj
注册会员
Rank: 2
初级会员


UID 62888
精华 0
积分 104
帖子 67
金钱 104 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-1-2
状态 离线
[推荐阅读] 高薪诚聘 广州飞捷招聘PHP游戏程序员
研究了几天,总算搞出来了,给大家测试下



<?php
print_r($_FILES);
?>
<HTML>
<HEAD>
<script>
        var file_to=0;
        function add_inp(){
                newInp = document.createElement("input");
                newInp.setAttribute("id","file_"+file_to);
        newInp.setAttribute("type","file");
        newInp.setAttribute("name","upfile[]");
        div1.appendChild(newInp);
                newInp = document.createElement('<input type="button" value="删除" onclick="del_inp('+file_to+')">');
                newInp.setAttribute("id","file_del_"+file_to);
        div1.appendChild(newInp);
        newInp = document.createElement('<BR />');
                newInp.setAttribute("id","file_br_"+file_to);
        div1.appendChild(newInp);
                file_to++;
    }
        function del_inp(file_id){
                div1.removeChild(document.getElementById("file_"+file_id));
                div1.removeChild(document.getElementById("file_del_"+file_id));
                div1.removeChild(document.getElementById("file_br_"+file_id));
    }
       

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
<BODY>
<FORM METHOD="post" ENCTYPE="multipart/form-data" name=f1>
<div id=div1>
</div>
<INPUT TYPE="button" VALUE="增加上传" onclick=add_inp()>
<INPUT TYPE="button" VALUE="减少上传" onclick=del_inp()><br>
<INPUT TYPE="submit" VALUE="提 交" NAME="Submit">
</FORM>
</BODY>




爱资讯92jijin.com
2008-5-7 09:15 AM#4
查看资料  访问主页  Blog  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.024618 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP