[mod_python] subscribe Uploading file troubles...

Simon simonrolin at gmail.com
Wed Nov 21 20:14:25 EST 2007


Thanks for your (again) very fast answer...
Unfortunately, I'm getting the same results without the value=""...
About versions, 'SERVER_SOFTWARE': 'Apache/2.2.4 (Ubuntu) mod_python/3.3.1
Python/2.5.1'...
Do you think I could be linked to the version I'm using? Should I try with
another one?

Simon

2007/11/22, Graham Dumpleton <graham.dumpleton at gmail.com>:
>
> Do you get the same if you remove:
>
>   value=""
>
> from options for file upload form input element.
>
> Sorry, I don't do file upload stuff very often so just comparing it to:
>
>   http://webpython.codepoint.net/mod_python_publisher_file_upload
>
> and I see that as a difference.
>
> BTW, what version of mod_python are you using? Hope you aren't using a
> really old version and following documentation for newer version.
>
> Graham
>
> On 22/11/2007, Simon <simonrolin at gmail.com> wrote:
> >
> >
> > ---------- Forwarded message ----------
> > From: Simon <simonrolin at gmail.com>
> > Date: 22 nov. 2007 01:48
> >  Subject: Re: [mod_python] subscribe Uploading file troubles...
> > To: Graham Dumpleton <graham.dumpleton at gmail.com>
> >
> >
> >
> >  2007/11/21, Graham Dumpleton <graham.dumpleton at gmail.com>:
> >
> > > On 22/11/2007, Simon <simonrolin at gmail.com> wrote:
> > > >
> > > >
> > > > ---------- Forwarded message ----------
> > > > From: Simon < simonrolin at gmail.com>
> > > > Date: 21 nov. 2007 20:39
> > > >  Subject: Re: Mod_python Digest, Vol 56, Issue 21
> > > > To: mod_python at modpython.org
> > > >
> > > > Hi all of you,
> > > >
> > > > I'm new to modpython and I'm actually facing some problem when
> trying to
> > > > upload file.... I've read a lot but have not found any answer...
> > > >
> > > > Here is my HTML of my form:
> > > > <form action=Upload2.py method=Post
> > > > enctype="mutlipart/form-data">
> > > >
> > > > <input type=
> > > > "file" name="file" value=""><
> > > > div class="button"><input type=
> > > > "submit" name="submit" value="Rechercher"
> > > > class="submit" /></div></
> > > > form>
> > > >
> > > > and here is Upload2 function:
> > > >
> > > > def Upload2(req):
> > > >     timer = ExecTime()
> > > >     _session(req)
> > > >     myPage = page.Page(req,"Ajouter une photo")
> > > >     fileitem = req.form['file']
> > > >     myPage.add("Type is :" + str(type(fileitem)) + "<br />")
> > >
> > > A Python type string has <> characters in it. Parse it through
> > > cgi.escape() so you can view the actual type string. Then repost
> > > output as at the moment can't tell what the type is.
> > >
> > > Graham
> >
> >
> > Graham, thanks for answering so fast....
> >
> >  So, fileitem or req.form['file'] is from type <class
> > 'mod_python.util.StringField' >...
> >  If I do the same with fileitem.file, i have : <type ' cStringIO.StringI
> '>
> >
> >  Any idea? Why does fileitem.filename is None?
> >
> >  Thanks a lot for your help, really great!
> >
> >  Simon
> >
> > > >     if fileitem.filename :
> > > >         import os
> > > >         # strip leading path from file name to avoid directory
> traversal
> > > > attacks
> > > >         fname = os.path.basename(fileitem.filename)
> > > >         # build absolute path to files directory
> > > >         dir_path = os.path.join(os.path.dirname(req.filename),
> 'files')
> > > >         open(os.path.join(dir_path, fname), 'wb').write(
> > > > fileitem.file.read())
> > > >         myPage.add("The file" + fname)
> > > >     else:
> > > >         myPage.add('No file was uploaded')
> > > >         myPage.add(str(req.form))
> > > >     myPage.execTime = timer.stop()
> > > >     myPage.send()
> > > >
> > > >
> > > > myPage being a class to generate the page....
> > > >
> > > > and here is the result...:
> > > > Type is :
> > > > No file was uploaded{'submit': [Field('submit', 'Rechercher')],
> 'file':
> > > > [Field('file', '08 - Big Furry Head.m4a')]}
> > > >
> > > > Does someone have any idea of what's going wrong????
> > > >
> > > > It would be really great because it's actually 4 day's I'm trying to
> > find an
> > > > answer but without any succes...
> > > >
> > > > I promise you I'have really search a lot before sending you this
> > email....
> > > >
> > > > Thanks a lot for your answers!
> > > >
> > > > Simon
> > > >
> > > >
> > > > --
> > > > --  :-) Simon Rolin ;-)  --
> > > > _______________________________________________
> > > > Mod_python mailing list
> > > > Mod_python at modpython.org
> > > >
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > --  :-) Simon Rolin ;-)  --
> >
> > --
> > --  :-) Simon Rolin ;-)  --
>



-- 
--  :-) Simon Rolin ;-)  --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20071122/06a6dd9d/attachment.html


More information about the Mod_python mailing list