[Zope] upload file from filename

John Hunter jdhunter@ace.bsd.uchicago.edu
Sun, 03 Mar 2002 13:35:21 -0600


>>>>> "Thomas" == Thomas B Passin <tpassin@mitretek.org> writes:

    Thomas> If you want to have a user using a browser to do this, it
    Thomas> can't be done directly because javascript is not allowed
    Thomas> to set the value of a file upload input element, for
    Thomas> security reasons.  The user has to type the file's path by
    Thomas> hand, that's the only way the filename can get into the
    Thomas> system.


Yes I experimented with this.  First I created a form which got the
names of the start file (eg, file1.dat) and end file (eg, file100.dat)
and the dir name, and passed these to a DTML method that created a
form with default values for all files in between

<dtml-let files="get_file_list_extern(file_begin.filename,file_end.filename)">
    <form action="addedMultipleFiles" method="post" enctype="multipart/form-data">
    <dtml-in files>
      <table>
	<tr><th align="right">File #<dtml-var sequence-index></th>
	<td><INPUT TYPE="file" NAME="file<dtml-var sequence-index>"
		   VALUE="<dtml-var expr=REQUEST.get('dir')><dtml-var sequence-item>" WIDTH=100></td></tr>
    </dtml-in>
  </table>
  <input type="SUBMIT" name="SUBMIT" value="Submit EEG">
  </dtml-let>

But as you say, this doesn't work because defaults values aren't
allowed for file input types.  Interestingly, this approach does work
with opera, which allows the use of default values but warns you when
you submit and you have to confirm each file separately.  But it
didn't work with Mozilla or IE.  Damn!  

I may end up having to go with a zip file after all. I'm very limited
in what I can do to the client side machines, from which the users
will upload the data, because I don't admin them.  I can just cross my
fingers and hope they have winzip installed...

Thanks for your input,
John Hunter