something like this
def youraction():
import shutil
if form.vars:
filename=request.vars.upload.filename
file=request.vars.upload.file
shutil.copyfileobj(file,open('path/'+filename,'wb'))
return dict()
but mind that open('path/'+filename,'wb') is vulnerable to directory
traversal attacks unless you validate or cleanup the filename.
On Jun 27, 5:20 am, antimatter <[email protected]> wrote:
> Hi,
> how do I upload a file in web2py without using SQLFORM ?
> So far, I've got my view with a HTML form:
>
> <form method="post" enctype="multipart/form-data">
> <input name="upload" type="file" size="60" maxlength="100000">
> <input type="Submit" value="Upload">
> </form>
>
> Now, how do I write a controller, which uploads the file and save's it
> to a specified folder?
> But everytime I select a file and upload it, request.vars.upload is
> None. How does it work?
>
> Best regards
> antimatter