Thx for your quick answer. But i try to do my form without sqlform (i didn't show all my form) because I have a form with a lot of fields, and they aren't all on the same page, i mean it's with anchor on the same page, and i dunno how to do the same thing with a factory. I can't upload a file with a simple form ?
And do you know how to change the name of the file when it's upload ? I have several upload fields. Le mercredi 16 décembre 2015 10:53:41 UTC+1, xmarx a écrit : > > in controller: > > def index(): > import os > form=SQLFORM.factory(Field('name'),Field('file', > 'upload',uploadfolder=os.path.join(request.folder,'uploads'))) > if form.process().accepted: > request.flash='file uploaded!' > return dict(form=form) > > > > in view index.html: > > {{extend 'layout.html'}} > > <h1>Upload File</h1> > {{=form}} > > > > > thats it. > > 16 Aralık 2015 Çarşamba 11:07:11 UTC+2 tarihinde Adrien yazdı: >> >> >> Hi everyone, >> Like i said in the title, i want to upload a file in a directory with a >> form. >> I saw another subject where he did what i want but with me, it doesn't >> work and i don't know why. >> >> This is my controller default.py : >> def test(): >> import shutil >> >> filename=request.vars.filename >> file=request.vars.file >> shutil.copyfileobj(file,open('path/'+filename,'wb')) >> return dict() >> >> def index(): >> return dict() >> >> And the view index.html : >> <form method="post" enctype="multipart/form-data" action="test"> >> <input name="upload" type="file" size="60" maxlength="100000"> >> <input type="Submit" value="Upload"> >> </form> >> >> Do someone knows how to fix this problem ? And sorry but I'm not english, >> i hope i'm clear for you. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.