Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6044685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:02:23+00:00 2026-05-23T07:02:23+00:00

Is there a web2py way of displaying images from a database table? Example: The

  • 0

Is there a web2py way of displaying images from a database table?

Example:

The model:

db.define_table=('images',Field('picture', 'upload' ))

The controller:

def somefunction(): to get the image.

How exactly should I “read” a picture from the database?

The view:

<img src="{{somefunction}}" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:02:23+00:00Added an answer on May 23, 2026 at 7:02 am

    As is, your model will not store the image in the database — instead, it will store the image on the filesystem, with its new filename stored in the database (in the ‘picture’ field). If you want to store the image itself in the database, use the following:

    db.define_table('images',
        Field('picture', 'upload', uploadfield='picture_file')
        Field('picture_file', 'blob'))
    

    Whether you store the images on the filesystem or in the database, you can use the same method to retrieve them. The ‘welcome’ scaffolding application includes the following download() action in the default.py controller:

    def download():
        return response.download(request, db)
    

    To retrieve an image, just do something like:

    <img src="{{=URL('default', 'download', args=picture_name)}}" />
    

    where picture_name is the value stored in the ‘picture‘ field of the ‘images‘ table for the particular image you want to retrieve.

    For more details, see here and here.

    If you need further help, try asking on the mailing list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why (for example web2py) do you return data from a controller in a dictionary
There is a field in my company's Contacts table. In that table, there is
In web2py, is there a way to have a piece of common code be
What is the recommended way to log application-specific messages in web2py? I found the
There is a table view with three sections. The last section may contain many
I have users upload files into a fake directory structure using a database. I
I am trying to query a MySQL database using webpy. From the SQL query,
I'm using the python-openid library from Janrain at http://openidenabled.com/python-openid/ I adapted their Django example
There is a conversion process that is needed when migrating Visual Studio 2005 web
There are two weird operators in C#: the true operator the false operator If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.