On 9月20日, 下午7时15分, "ashok raavi" <[EMAIL PROTECTED]> wrote:
> On 9/20/07, slummer <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 9月20日, 下午6时21分, Anand <[EMAIL PROTECTED]> wrote:
> > > On 20-Sep-07, at 3:08 PM, slummer wrote:
>
> > > > When i post a file  to web.py, how can i get the file's name?
> > > > For example, I commit a file which full path is "c:\temp\example.xml"
> > > > to web.py, how can i get this  file name:"example.xml" by web.py?
>
> > > i = web.input(f={})
> > > print i.f.filename, i.f.value
>
> > Thanks your answer, i follow your example in my code, but get the
> > following error:
>
> > exceptions.AttributeError at /file
> > 'dict' object has no attribute 'filename'
>
> > how can i modify my code? Eager for your help !
> > Thanks very much!
>
> it's working for me, my code looks like
>
> class index:
>     def GET(self):
>         print render.form()
>     def POST(self):
>         i = web.input(x={})
>         print i.x.filename
>
> and my form is
>
> <form method="post" enctype="multipart/form-data">
> <input type="file" name="x">
> <input type="submit" value="submit">
> </form>
>
> without 'enctype' in form its not getting the filename, but its not raising
> any exception
>
>
>
> --
> ashok raavi


I am inspired by your work, My error occured by a diffrence between
name in form and code.
the code is:
i = web.input(f={})
I use "f", but in form, it is following:

<form name="form2" enctype="multipart/form-data" method="post" >
    <input name="xml" type="file" size="80" maxlength="80">
    <input type="submit" name="Submit" >
</form>

====
the input name is "xml", obviously, "xml" does't agree with "f". so i
change my code in the following:

        i = web.input(xml={})
        print i.xml.filename, i.xml.value

then, everything is fine!

thanks Anand and ashok raavi


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to