docs/versioned_docs/version-2.61.0/how-to/loading-image-pdf-from-db.md
This guide shows how to upload and view images and PDFs using the base64 string format.
</div> <div style={{paddingTop:'24px', paddingBottom:'24px'}}>id field will be present by default to create a unique identifier for each record in our database table.pdf and image.varchar as datatype for the pdf and image columns.<i>While we are using the ToolJet Database for this guide; feel free to use other databases while applying the same principles.</i>
<div style={{ width: '100%', marginBottom:'15px', marginTop:'15px'}}> </div> </div> <div style={{paddingTop:'24px', paddingBottom:'24px'}}>{{"pdf/*"}} - this ensures that the Filepicker only accepts PDF files.{{"image/*"}} setting for the Accept file types property in the imagePicker component, as it's intended for image uploads.testDB as Table name, and Create Row as Operations. Name this query uploadFiles.pdf and image.pdf column:{{components.pdfPicker.file[0].base64Data}}
image column:{{components.imagePicker.file[0].base64Data}}
<i>In the above query, we are using the <b>exposed variables</b> of both Filepicker components to get the base64 strings of the files we had uploaded earlier.</i>
<div style={{ width: '100%', marginBottom:'15px', marginTop:'15px'}}> </div>On click, Action - Run Query and Query - uploadFiles.The upload process is now complete. Whenever files are selected in the Filepicker components and the upload button is clicked, the base64 strings of these files will be automatically written to the database.
</div> <div style={{paddingTop:'24px', paddingBottom:'24px'}}>testDB as Table name, and List rows as Operations.{{'data:image;base64,' + queries.getFiles.data[0].image}}
{{'data:pdf;base64,' + queries.getFiles.data[0].pdf}}
<i>The provided code constructs a Data URL to display the base64-encoded data as an image or PDF.</i>
Here's what our final interface will look like:
<div style={{ width: '100%', marginBottom:'15px', marginTop:'15px'}}> </div> <i> You can also use transformations in the query response and concat `data:image/jpeg;base64,` to the base64 data. </i>Using the above logic, you can upload and view files in ToolJet using the base64 data.
</div>