[Zope] filename property of variable

Thomas B. Passin tpassin@mitretek.org
Mon, 9 Jul 2001 14:42:02 -0400


I'm a little lost.  When I tried it, I got a non-empty string for each file
input field that had a filename, and there was an empty string for each one
where the user hadn't entered anything.  Isn't that what you want?  That
way, you can test to see if anything was entered.

Let me show you what I was testing.  Here is my form, with two file-type
inputs:

<html>
    <form action='see_request2 '>
        <input type='file' name='file1'><br>
        <input type='file' name='file2'><br>
        <input type='submit' value='Try It'>
    </form>
</html>

Here's my handling form, see_request2:

<html>
    <dtml-in "REQUEST.form.keys()">
        <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]">
        <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br>
    </dtml-in>
</html>

Here's the result, copied for the screen, where I entered "aaa" for the
first file name and nothing for the  2nd file name:

file1:aaa (passed if)
file2:

You see, it DOES differentiate between the fields where the user entered a
filename and those where the user didn't.

Isn't that what you want? If not, I need more clarification.  I'm probably
assuming something without realizing.  Better show us a (shortened) sample
of the form, at least.

Tom P



[Laurie Nason]

> I tried this and it doesn't differentiate between ones where the user has
> entered a file to upload and ones where they haven't.
> I really need to be able to call the .filename method to see if it has
one -
> but _['sequence-item'].filename doesn't like the fact that the
> _['sequence-item'] returns a string (thanks Casey again on a different
> post!) rather than the object itself.
> What I would like to be able to do is to call
>     <dtml-if expr="_.getitem(sequence-item).filename">
>
> But you can't escape the sequence-item again due to the fact that it
returns
> a string...AARRGGHHH!!!
>
> Any ideas???
>