Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-12 Thread Dave S


On Monday, November 11, 2019 at 10:39:58 PM UTC-8, Maurice Waka wrote:
>
> Thanks.
> Let me work it out.
> Regards
>
>>
>>
Also note that a file uploaded to an upload field is not stored with the 
name the user passed to the upload form; instead, it is stored with a 
mangled, er, obfuscated name, and to find the file you should expect to do 
a db query.  See Chapter 6 under Field Types.

/dps



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/33a47191-56bd-410f-8aec-9ddf08ff7063%40googlegroups.com.


Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Maurice Waka
Thanks.
Let me work it out.
Regards

On Tue, Nov 12, 2019, 01:01 Dave S  wrote:

>
>
> On Monday, November 11, 2019 at 12:10:53 PM UTC-8, Maurice Waka wrote:
>>
>> But I did upload and the image is in the folder.
>>
>
> How are you generating the URL for showarticle()?
>
> Also, I think you can just do an ordinary file open(), rather than having
> to import PIL and doing an Image.open()
>
> BTW, I handle images as  tags, where src=showimg(id), and showimg()
> reads the file.  I also have an example, maybe previously posted, where I
> use download() instead of a custom showimg(),so the controller does a
> select on the upload table, and then
> return dict(img=row.fdata)
>
> and the view has
> {{=IMG(_src=(URL"download", img), _alt="test image")}}
>
> Good luck!
>
> Dave S
> /dps
>
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GbwQoJymKns/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/6301fedd-ed05-484f-bffc-6afeb2f200cf%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CALkNK56Ch%3DFRntkCB%2BFhN14VV2BHGsUcDvWiayJ1wR8ej36WZA%40mail.gmail.com.


Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Dave S


On Monday, November 11, 2019 at 12:10:53 PM UTC-8, Maurice Waka wrote:
>
> But I did upload and the image is in the folder.
>

How are you generating the URL for showarticle()?

Also, I think you can just do an ordinary file open(), rather than having 
to import PIL and doing an Image.open()

BTW, I handle images as  tags, where src=showimg(id), and showimg() 
reads the file.  I also have an example, maybe previously posted, where I 
use download() instead of a custom showimg(),so the controller does a 
select on the upload table, and then
return dict(img=row.fdata)

and the view has
{{=IMG(_src=(URL"download", img), _alt="test image")}}

Good luck!

Dave S
/dps



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6301fedd-ed05-484f-bffc-6afeb2f200cf%40googlegroups.com.


Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Maurice Waka
But I did upload and the image is in the folder.

On Mon, Nov 11, 2019 at 3:48 PM Ruslan Gareev  wrote:

> Hi, looks like your request.args(0) is empty.
>
> понедельник, 11 ноября 2019 г., 15:37:31 UTC+5 пользователь Maurice Waka
> написал:
>>
>> I'm trying to retrieve an uploaded image from the uploads folder using
>> this
>> 
>> example.
>>
>> I keep on being redirected back to the index page.
>>
>> I also tried this option with the same result.
>>
>> This is the controller code:
>>
>> def showarticle():
>> id = request.args(0) or redirect(URL('default', 'index'))
>> article = Article[id]
>> try:
>> import os
>> from PIL import Image
>> except:
>> return
>> stream=Image.open(request.folder + 'uploads/' + id)
>> return response.stream(stream, attachment=False, article=article)
>>
>> How can I get this right?
>> Regards
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GbwQoJymKns/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/d9f38307-39a9-4b1b-b126-a440a8ad8d07%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CALkNK55wO3QXDs6y4yLhYpeMyAWg0wxtW92U%3Dhu2VxbjdfuHWg%40mail.gmail.com.