commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David.Paw...@rnib.org.uk
Subject RE: [FileUpload] new user, querying functionality? commons-fileup load
Date Tue, 31 Aug 2004 13:18:17 GMT
 

    -----Original Message-----
    From: Schalk Neethling 
    
    How many files do you want to upload at a time? I have had 
    no problem uploading up to five at one time using either 
    five file fields or reading a directories files and loading 
    them as a list of tick boxes.

I want it to be user defined? 1..n
  
I have a javascript solution, recurses on a function to
add more 'single file' uploads. Works with ie6 and firefox;
just building a tomcat install to see if I can do the upload!


js below if interested:
Not tested for full accessibility yet.

regards DaveP


<html>
  <head><title>Web Toaster Sample Form</title>
  <head>
  <title>Multiple File Uploads</title>



<script language="JavaScript1.2" type="text/javascript">



function bn() {
browserName=navigator.appName;
browserVer=parseInt(navigator.appVersion);
if ((browserName=="Netscape" && browserVer>=3) )
version="ns";

else
  if (browserName=="Microsoft Internet Explorer" && browserVer>=4)
   version="ie";
return (version);


}


function showUpload(){
 var e=window.event || arguments.callee.caller.arguments[0];
	var obj = null;
	var position = 0;
	if (bn() == "ns"){
		obj = e.target;
		var parentE = obj.parentNode; //the <LI>
		var Gparent = parentE.parentNode;
	}else{
		obj = event.srcElement;
		var parentE = obj.parentElement; //the <LI>
		var Gparent = parentE.parentElement;
	}
	if (obj == null) alert("Oh dear!");

	
	
	if (obj.value == " Remove this file?"){
		// delete the following sibling
		Gparent.removeChild(parentE);
		// fixup the file ids because they have to be unique?
		for (var i=0; i < Gparent.children.length; i++){
			LI = Gparent.children[i];
			var INPUT = LI.children[0];
			INPUT.setAttribute("id", "file" + i);
			INPUT.setAttribute("name", "file" + i);
		}
		}else{
		var newLI = document.createElement("li");
		var newFU = document.createElement("input");
		newFU.setAttribute("type", "file");
		var lth = 0;
		if (bn() == "ns"){
		    lth = Gparent.childNodes.length;
		    }
                else {
		    lth = Gparent.children.length;
		    }
                    
		newFU.setAttribute("id", "file" + lth);
		         //(Gparent.children.length)); // file + end of list
		newLI.appendChild(newFU);

		var newBU = document.createElement("input");
		newBU.type= "button";
		newBU.value= "Upload another file?";
		newBU.onclick = showUpload;
		newLI.appendChild(newBU);

		var OL = document.getElementById("ULlist");
		OL.appendChild(newLI);
		Gparent.appendChild(newLI);
		if (bn() =="ns"){
		  parentE.childNodes[0].value= " Remove this file?";
		}
		else {
		  parentE.children[1].value = " Remove this file?";
		     }

	}
}
</script>

</head>
<body>

	<form enctype="multipart/form-data" method="post"
action="/cgi-bin/wet.py/formatted">
		<p>
			<input type="file" name="fo"/>
			<input type="submit" value="Format..."/>
		</p>
	</form>

	<fieldset style="padding: 10px;">
	     <legend><b>Upload a File</b></legend><br />

		<form method="post" action="" name="form">
			<ol id="ULlist">
			   <li>
			     <input type="file" id="file0">
			     <input type="button"  onclick="showUpload();"

                              value="Upload another file?">
			   </li>
			</ol>
			<input type="submit" value="Submit..."/>
		</form>

	</fieldset>
</body>
</html>





-- 
DISCLAIMER: 

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged. If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system. 

RNIB endeavours to ensure that emails and any attachments generated by 
its staff are free from viruses or other contaminants. However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments. 

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent 
those of RNIB. 

RNIB Registered Charity Number: 226227 

Website: http://www.rnib.org.uk 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message