UPDATE:

The error I was getting was caused by a missing ')' in the view so
fixing that has gotten me to a new error.

I simplified my model to how you have pbreit just to make things
easier.

But when I try to display the image like so:

<img src="{{=URL('download', args=img['upload'])}}" />

I get a 400 error in the Chrome Console:

http://127.0.0.1:8000/sos_test/default/download/FieldStorage%28%27upload%27%2C%20%27Mars.jpg%27%2C%20%27%5Cxff%5Cxd8%5Cxff%5Cxe0%5Cx00%5Cx10JFIF%5Cx00%5Cx01%5Cx01%5Cx00%5Cx00%5Cx01%5Cx00%5Cx01%5Cx00%5Cx00%5Cxff%5Cxfe%5Cx00%3ECREATOR%3A%20gd-jpeg%20v1.0%20%28using%20IJG%20JPEG%20v62%29%2C%20default%20quality%5Cn%5Cxff%5Cxdb%5Cx00C%5Cx00%5Cx08%5Cx06%5Cx06%5Cx07%5Cx06%5Cx05%5Cx08%5Cx07%5Cx07%5Cx07%5Ct%5Ct%5Cx08%5Cn%5Cx0c%5Cx14%5Cr%5Cx0c%5Cx0b%5Cx0b%5Cx0c%5Cx19%5Cx12%5Cx13%5Cx0f%5Cx14%5Cx1d%5Cx1a%5Cx1f%5Cx1e%5Cx1d%5Cx1a%5Cx1c%5Cx1c%20%24.%5C%27%20%22%2C%23%5Cx1c%5Cx1c%287%29%2C01444%5Cx1f%5C%279%3D82%3C.342%5Cxff%5Cxdb%5Cx00C%5Cx01%5Ct%5Ct%5Ct%5Cx0c%5Cx0b%5Cx0c%5Cx18%5Cr%5Cr%5Cx182%21%5Cx1c%2122222222222222222222222222222222222222222222222222%5Cxff%5Cxc0%5Cx00%5Cx11%5Cx08%5Cx00d%5Cx00K%5Cx03%5Cx01%22%5Cx00%5C
400 (BAD REQUEST)

There is that field storage again.  I tried doing
img['upload'].filename as recommended in this link:

http://groups.google.com/group/web2py/browse_thread/thread/9562da3b8bfb4c96/5cf5dca2885e473c?lnk=gst&q=How+to+retrieve+data+from+FieldStorage#5cf5dca2885e473c

But I got an error that the object was a string and .fieldname
wouldn't work.

Thoughts?

I'm using SQLForm to upload the image.  Maybe I'm doing something
strange upon upload to store it in such a weird format?

On Jul 3, 1:04 pm, pbreit <[email protected]> wrote:
> I would suggest following the Book more 
> closely:http://web2py.com/book/default/chapter/03
>
> db.define_table('image',
>    Field('caption'),
>    Field('file', 'upload'))
>
> <img src="{{=URL('download', args=image.file)}}" />

Reply via email to