Anyone know how to pull an uploaded file from the database locally on the
server? I want to do some server-side processing on the file and then
re-insert it to the database. I'm not sure I understand how to get the
local path on the server of the uploaded file. The static/upload directory
appends an random ID to the files. How can I get the path to an uploaded
file so that I can manipulate it?
I'm using a standard model form like the following:
db=DAL('sqlite://storage.db')
db.define_table('test',
Field('package_name'),
Field('attachment','upload',default=''))
My controller:
form=SQLFORM(db.testplug)
if form.accepts(request.vars):
response.flash='Files uploaded'
filename = request.vars.attachment.filename
filereference = request.vars.attachment.file
print filename
print filereference
records=SQLTABLE(db().select(db.test.ALL),upload=download)
return dict(form=form,records=records)
My view:
{{=records}}
[{{=A('delete all',_href=URL('delete_storage'))}}]