[Zope] Sample for uploading multiple files through DHTML

iap@y2fun.com iap@y2fun.com
Mon, 29 Oct 2001 12:27:22 +0800


This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C16075.0F07E3E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I am much benefit from the "Local File System" Product and
I noticed that "upload file" through the browser is a feature appeared in
many other products too. Sometimes, upload multiple files at once is
helpful.
Dut to the limitation of browser, upload a folder or selected several files
is not achievable.

I have a work around for "upload several selectef files" by DHTML
(=javascript+css).
It's just a sample for people who wants a hint for doing multiple files
uploading.
The scenario is to choose files one-by-one.
Please refer to the attachment. Just save it and drop into the browser (IE).
Then try to choose a file, after that another file-field will appear for
next input.

Maybe someone had done sort of this before. I have no idea.
But if uploading multiple files is a feature there when we need it.
It's would be good.

Iap, Singuan
iap@y2fun.com

------=_NextPart_000_000D_01C16075.0F07E3E0
Content-Type: text/html;
	name="addMultifiles.html"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="addMultifiles.html"

<!--
  This is the example for doing multiple file uploading.

  This is not cross-browser. It works only or IE.
  I believe that just a minor modifition is required for it to work on =
browsers
  of Netscape-like DOM. ( I don't have a NS installation now, sorry)

  Hint for people concerns about cross-browser: Netscape doesn't use =
"document.all".

  Enjoy!
  iap@y2fun.com
  Oct 29, 2001
-->
<html>
<head>
<script language=3D"javascript">
file_count=3D1
function addFileField(widget){
   if (widget.value=3D=3D'') return null
   file_count.value=3Dfile_count
   ++file_count
   obj=3Deval('document.all.file'+file_count+'div')
   obj.innerHTML=3D'<input type=3Dfile name=3Dfile'+file_count+'  =
onchange=3D"addFileField(this)" size=3D20><div =
id=3Dfile'+(file_count+1)+'div></div>'
}
</script>
</head>
<body>
<form method=3Dpost enctype=3Dmultipart/formdata=20
      action=3D"use <dtml-var REQUEST> to see the result">
<input type=3Dfile name=3Dfile1 size=3D20 =
onchange=3D"addFileField(this)">
<input type=3Dhidden name=3Dfile_count value=3D0>
<div id=3Dfile2div></div>
</form>
</body>


------=_NextPart_000_000D_01C16075.0F07E3E0--