Author Topic: a upload template  (Read 15016 times)

0 Members and 1 Guest are viewing this topic.

Offline nansenat16

  • Occasional poster
  • *
  • Posts: 3
    • View Profile
a upload template
« on: May 21, 2007, 12:26:54 PM »
Share my upload template ;D
Code: [Select]


[upload]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>HFS %folder%</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <style type="text/css">
  %style%
  </style>
</head>
<body>
%login-link%
%loggedin%
<script type="text/javascript">
var s1, s2;
if (window.parent.progress) s1 = '" target=_parent', s2 = 'CLOSE';
else s1 = '+progress"', s2= 'ADD';
document.write('<a href="~upload'+s1+' class=button onClick="if (frm.upbtn.disabled) return false;"><img src="/~img10" /> '+s2+' PROGRESS FRAME</a>');
</script>
<a href="." target=_parent class=button><img src="/~img21" /> CANCEL UPLOAD</a>
<div style="margin-top:60px" id=folderlabel>folder</div>
<div id="folder">%folder%</div>
<div id="body">

<script type="text/javascript">
<!---
/*
Designer:Nansenat16(nansenat16+js@gmail.com)
Web:http://nansen.ispaz.blogdns.org
Date:2006/08/21
Licence:BSD licence
Test browse:Firefox 1.5.0.6、Opera 9.01、IE6 SP2
*/
count_n=1;//del_button count
count_m=1;//upload file count
function add_upload(){
text=document.createElement("input");
text.type="file";
text.size="70";
text.setAttribute('onchange','addchk()');//For Firefox Opera
text.onchange = function(){//For IE
addchk();
};
text.name="fileupload"+count_m;
document.getElementById("upload_div").appendChild(text);
count_m++;
}
function add_del_button(){
text=document.createElement("input");
text.type="button";
text.value="Delete";
text.id="del"+count_n;
text.name="del_button";
text.setAttribute('onclick','delchk(this.id)');//For Firefox Opera
if ((document.all)&&(document.getElementById)){//For IE
text["onclick"]=new Function("delchk(this.id)");
}
document.getElementById("upload_div").appendChild(text);
count_n++;
}
function get_del_num(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
for(m=0;m<del_button.length;m++){
if((del_button[m].id)==did){
del_num=m;
}
}
return del_num;
}
function get_previous_id(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
for(m=0;m<del_button.length;m++){
if((del_button[m].id)==did){
if(m>=1){
previous_id=del_button[m-1].id+"";
}else{
previous_id=-1;
}
}
}
return previous_id;
}
function del_file_upload(did){
upload_ary=document.getElementsByTagName("input");//get all upload input object
if(upload_ary.length==0){//For IE
upload_ary=document.getElementsByTagName('input');
}
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<upload_ary.length;n++){
if(upload_ary[n].name.match(/^fileupload+\S/)){
tmp_ary[tmp_n]=upload_ary[n];
tmp_n++;
}
}
upload_ary=tmp_ary;
del_num=get_del_num(did);
document.getElementById("upload_div").removeChild(upload_ary[del_num]);
count_m--;
}
function del_del_button(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
del_num=get_del_num(did);
document.getElementById("upload_div").removeChild(del_button[del_num]);
}
function addchk(){
upload_ary=document.getElementsByTagName("input");//get all upload input object
if(upload_ary.length==0){//For IE
upload_ary=document.getElementsByTagName('input');
}
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<upload_ary.length;n++){
if(upload_ary[n].name.match(/^fileupload+\S/)){
tmp_ary[tmp_n]=upload_ary[n];
tmp_n++;
}
}
upload_ary=tmp_ary;
tmp_chk=true;
n=0;
while(tmp_chk==true&n<upload_ary.length){
if(upload_ary[n].value==""){
tmp_chk=false;
}
n++;
}
if(tmp_chk==true){
if(count_m>0){
tmp=document.getElementById("add_button");
if(tmp){
document.getElementById("upload_div").removeChild(tmp);
}
add_del_button();
}
add_upload();
}
}
function delchk(did){
del_file_upload(did);
del_del_button(did);
}
-->
</script>


<form name="frm" action="." target=_parent method=post enctype="multipart/form-data" onSubmit="frm.upbtn.disabled=true; return true;">
<div id="upload_div" style="width:100%"><input type="file" name="fileupload0" onChange="addchk()" size="70"/></div>
<noscript>
%upload-files%
</noscript>
<input name="upbtn" type="submit" value="Upload files" />
</form>
<br />Before uploading you may want to open a <a target=_blank href="/~progress">progress status window</a>.
</div>
<div id=footer>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Disk space: %diskfree%
</div>
</body>
</html>



[attachment deleted by admin]

Offline ledufe

  • Tireless poster
  • ****
  • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
Re: a upload template
« Reply #1 on: May 21, 2007, 09:03:05 PM »
very good code...
and it is very understandable...
<<LeDuFe>>

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12800
  • Country: it
    • View Profile
Re: a upload template
« Reply #2 on: May 23, 2007, 08:01:37 AM »
nice
default tpl will have this in the future, but don't know when :)

Offline Wasserfloh

  • Experienced poster
  • ***
  • Posts: 81
    • View Profile
Re: a upload template
« Reply #3 on: May 25, 2007, 02:54:19 PM »
Share my upload template ;D
Not badly only unfortunately no valid XHTML 1.0. I repaired that times:

Code: [Select]
[upload]
<!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=UTF-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <title>HFS %folder%</title>
  <style type="text/css">
  %style%
  </style>
</head>
<body>
<div>%login-link%
%loggedin%
<script type="text/javascript">
/* <![CDATA[ */
var s1, s2;
if (window.parent.progress) s1 = '" target="_parent"', s2 = 'CLOSE';
else s1 = '+progress"', s2= 'ADD';
document.write('<a href="~upload'+s1+'" class="button" onclick="if (frm.upbtn.disabled) return false;"><img src="/~img10" alt="" /> '+s2+' PROGRESS FRAME</a>');
/* ]]> */
</script>
<a href="." target="_parent" class="button"><img src="/~img21" alt="" /> CANCEL UPLOAD</a></div>
<div style="margin-top:60px" id="folderlabel">folder</div>
<div id="folder">%folder%</div>
<div id="body">

<script type="text/javascript">
/* <![CDATA[ */
/*
Designer:Nansenat16(nansenat16+js@gmail.com)
Web: http://nansen.ispaz.blogdns.org
Date: 2006/08/21
Licence: BSD licence
Test browse: Firefox 1.5.0.6, Opera 9.01, IE6 SP2
*/

count_n=1;//del_button count
count_m=1;//upload file count
function add_upload(){
text=document.createElement("input");
text.type="file";
text.size="70";
text.setAttribute('onchange','addchk()');//For Firefox Opera
text.onchange = function(){//For IE
addchk();
};
text.name="fileupload"+count_m;
document.getElementById("upload_div").appendChild(text);
count_m++;
}
function add_del_button(){
text=document.createElement("input");
text.type="button";
text.value="Delete";
text.id="del"+count_n;
text.name="del_button";
text.setAttribute('onclick','delchk(this.id)');//For Firefox Opera
if ((document.all)&&(document.getElementById)){//For IE
text["onclick"]=new Function("delchk(this.id)");
}
document.getElementById("upload_div").appendChild(text);
count_n++;
}
function get_del_num(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
for(m=0;m<del_button.length;m++){
if((del_button[m].id)==did){
del_num=m;
}
}
return del_num;
}
function get_previous_id(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
for(m=0;m<del_button.length;m++){
if((del_button[m].id)==did){
if(m>=1){
previous_id=del_button[m-1].id+"";
}else{
previous_id=-1;
}
}
}
return previous_id;
}
function del_file_upload(did){
upload_ary=document.getElementsByTagName("input");//get all upload input object
if(upload_ary.length==0){//For IE
upload_ary=document.getElementsByTagName('input');
}
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<upload_ary.length;n++){
if(upload_ary[n].name.match(/^fileupload+\S/)){
tmp_ary[tmp_n]=upload_ary[n];
tmp_n++;
}
}
upload_ary=tmp_ary;
del_num=get_del_num(did);
document.getElementById("upload_div").removeChild(upload_ary[del_num]);
count_m--;
}
function del_del_button(did){
del_button=document.getElementsByName("del_button");//get all delete button object
if(del_button.length==0){//For IE
tmp=document.getElementsByTagName('input');
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<tmp.length;n++){
if(tmp[n].name=="del_button"){
tmp_ary[tmp_n]=tmp[n];
tmp_n++;
}
}
del_button=tmp_ary;
}
del_num=get_del_num(did);
document.getElementById("upload_div").removeChild(del_button[del_num]);
}
function addchk(){
upload_ary=document.getElementsByTagName("input");//get all upload input object
if(upload_ary.length==0){//For IE
upload_ary=document.getElementsByTagName('input');
}
tmp_n=0;
tmp_ary=new Array();
for(n=0;n<upload_ary.length;n++){
if(upload_ary[n].name.match(/^fileupload+\S/)){
tmp_ary[tmp_n]=upload_ary[n];
tmp_n++;
}
}
upload_ary=tmp_ary;
tmp_chk=true;
n=0;
while(tmp_chk==true&n<upload_ary.length){
if(upload_ary[n].value==""){
tmp_chk=false;
}
n++;
}
if(tmp_chk==true){
if(count_m>0){
tmp=document.getElementById("add_button");
if(tmp){
document.getElementById("upload_div").removeChild(tmp);
}
add_del_button();
}
add_upload();
}
}
function delchk(did){
del_file_upload(did);
del_del_button(did);
}
/* ]]> */
</script>


<form name="frm" action="." target="_parent" method="post" enctype="multipart/form-data" onsubmit="frm.upbtn.disabled=true; return true;">
<div id="upload_div" style="width:100%"><input type="file" name="fileupload0" onchange="addchk()" size="70" /></div>
<noscript>
%upload-files%
</noscript>
<input name="upbtn" type="submit" value="Upload files" />
</form>
<br />Before uploading you may want to open a <a target="_blank" href="/~progress">progress status window</a>.
</div>
<div id="footer">
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Disk space: %diskfree%
</div>
</body>
</html>
« Last Edit: May 25, 2007, 03:35:14 PM by Wasserfloh »