Hey folks,
I'm attempting to upload a file directly without the use of a SQLForm but rather the ordinary FORM.
From previous threads regarding the topic i figured my controller should look something like this:
[code]
def index():
import shutil
form = FORM(
INPUT( _name="upload", _type="file"),
INPUT( _type="Submit", _value="Upload" ))
if form.accepts(request,session):
if form.vars:
filename=request.vars.upload.filename
file=request.vars.upload.file
shutil.copyfileobj(file,open('/path'+filename,'wb'))
return dict (form = form)
[/code]
yet no file appears in the folder of my path. I'm not sure if the problem is with my code or maybe elsewhere, for example permission based. I'm using a raspberry with a raspiban os. i Already tried to start python as root user.
Can someone spot a mistake in the code? has someone tried to run this on a debian based os and knows if its a permission problem? I'm aware of the potential dangers of the shutil.copyfileobj, so no worries about that.
Sincerely,