Typically we refer to an "upload" as going from client (browser) to server 
and "download" as going from server to client. response.download sends 
files from the server to the client, not the other way around.

You say you want to store files in static and then let the client download 
them. Do you need users to be able to upload files from the browser into 
static, or will you place them there yourself? If the former, use the usual 
upload field method described 
here: http://web2py.com/book/default/chapter/07#SQLFORM-and-Uploads. 
However, in the upload field definition, specify:

Field(..., uploadfolder=os.path.join(request.folder, 'static', 'pdf'))

That will tell it to store the file in /static/pdf instead of the default 
/uploads folder. (Note, you'll have to do 'import os' to use os.path.join.)

Once files are in /static, you don't need the download() function or 
response.download to download them. Instead, you can access them directly 
via their URLs:

URL('static', 'pdf', args=filename)

Note, you'll need to get the filename from your upload field if you 
uploaded the file.

Anthony

On Tuesday, October 25, 2011 11:42:57 PM UTC-4, lucas wrote:
>
> hello one and all, 
>
> i know i have a lot of posts.  i will become proficient soon.  i am 
> getting the hang of web2py's rythums. 
>
> i get the response.download function, it is for the server to receive 
> files from the client and put the files onto the server. 
>
> i want to allow the user to download files to the client computer.  so 
> how would i best do an upload from the server to the client. 
> specifically, i want to store files under static or static/pdf and 
> upload static files from there to the client. 
>
> thank you in advance and have a great day.  lucas

Reply via email to