Yeah I checked my controller and it's uploading images to
Field('image', 'upload',
uploadfolder=os.path.join(request.folder,'uploads/profiles/')

Is there a default directory where the download() function wants images to
be?


On Wed, Dec 5, 2012 at 5:55 PM, Daniele Pestilli <[email protected]>wrote:

> hmm still not working. I think it's because I set the upload directory to
> uploads/profiles/ so it's not finding the image. Maybe if I change that
> setting it will work...
>
>
>
> On Wed, Dec 5, 2012 at 5:43 PM, Niphlod <[email protected]> wrote:
>
>> ehm.... in html you need to do <img src="/something/photo.png" />.
>> {{=URL('default', 'download', args=row.image)}} is just the portion to
>> put into the img tag as the src's attribute value
>>
>> {{=IMG(
>>     _src=URL('default', 'download', args=row.image)
>> )
>> }}
>>
>> is the right one!
>>
>> On Wednesday, December 5, 2012 6:36:10 PM UTC+1, Daniele wrote:
>>>
>>> I have def download(): return response.download(request,db) in my
>>> controller. But when I put {{=URL('default', 'download', args=row.image)}}
>>> in my view I'm just getting a string. Perhaps because the file was not
>>> saved to this directory?
>>>
>>> On Wednesday, December 5, 2012 2:25:57 PM UTC, Anthony wrote:
>>>>
>>>> You do not specify the "uploads" directory in the URL. Instead, you
>>>> need to define a function that calls response.download() and pass the
>>>> filename to that function via the last URL argument (i.e.,
>>>> request.args[-1]). In fact, this function is already provided for you
>>>> in the "welcome" app:
>>>>
>>>> def download():
>>>>     """
>>>>     allows downloading of uploaded files
>>>>     http://..../[app]/default/**download/[filename]
>>>>     """
>>>>     return response.download(request,db)
>>>>
>>>> So, your URL should be URL('default', 'download', args=row.image).
>>>>
>>>> This is discussed 
>>>> here<http://web2py.com/books/default/chapter/29/03#An-image-blog>,
>>>> here<http://web2py.com/books/default/chapter/29/07#SQLFORM-and-uploads>,
>>>> here <http://web2py.com/books/default/chapter/29/04#response>, and 
>>>> here<http://www.web2py.com/examples/default/examples#database_examples>(example
>>>>  33).
>>>>
>>>> Anthony
>>>>
>>>> On Wednesday, December 5, 2012 9:06:57 AM UTC-5, Daniele wrote:
>>>>>
>>>>> Guys I know this sounds simple but I'm having a hard time displaying
>>>>> uploaded images. I have an upload field in my model where logged in users
>>>>> can upload an image. But in my views when I try to do
>>>>> {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that
>>>>> refers to db(db.auth_user.id > 0).select() nothing is being returned.
>>>>> However, row.image returns a string which is the name of the file.
>>>>> How can I display the image correctly?
>>>>>
>>>>> Thanks!
>>>>>
>>>>  --
>>
>>
>>
>>
>
>

-- 



Reply via email to