Learn py4web

Unit 18: File uploads and data URLs

In this unit, we will learn how to upload a file to the server, and how to display image previews of files to upload.

We will also learn that images can be represented via data URLs, which are strings that represent the bytes in images, encoded in such a way that they can be easily stored in the database, or uploaded via POST requests. A typical data URL for an image begins with data:image/jpeg;base64, followed by the bytes of the image encoded in base64 format. Data URLs enable us to convert images into strings, and thus, treat them just like any other simple data type, such as integers, floating point, etc, that can be send back and forth between browser and server via json and stored in the database. See an example of this in the adding images to contacts video.