This tutorial is designed as a quick "How Do I Work With Binary Data" tutorial. It walks through the steps necessary to upload an image to a database. Every webNetwork 6.0 installation ships with a database called webNetwork Demo Database, so you already have the database necessary to complete this tutorial on your own system.
Setup the database table.- Start Form Builder.
- Go to the Form Properties tab.
- Click Wizard.
- Choose Save to Database and hit Next.
- Choose "webNetwork Demo Database". Enter sa as the User ID and click Next.
- Select Create New Table. Enter EmployeeImages as the table name.
- Change the Primary Key Name to employeename and the data type to Text.
- Click Done.
- Click Create/Modify Table in the toolbar.
- Click Add Field.
- Enter employeepicture as the Field Name and choose Binary as the Type of Data. Hit Save then Done.
- Click Add Field.
- Enter originalfilename as the Field Name and choose Text as the Type of Data. Hit Save then Done.
- Click Add Field.
- Enter contenttype as the Field Name and choose Text as the Type of Data. Hit Save then Done.
- Hit Done to close the Table Manager.
Create the form frontend- Click on the Form Designer tab.
- Click New Form Frontend in the toolbar.
- Choose Orange as the template.
- Click the Form Fields tab.
- Choose Text Field for employeename.
- Choose File Upload for employeepicture.
- Do not include contenttype or originalfilename on the form.
- Click Save.
- Save the form and call it EmployeePictures (this name will be referenced in future tutorials).
Configure the required field (employeename)- Right click the text field for employeename and choose Data Behavior.
- Click the Validation tab.
- Check the box for Required.
- Click Save.
Configure the file upload field- Right click the yellow File Upload field and choose Data Behavior.
- Change Upload To to Database.
- Enter jpg,gif,png in the Allowed File Extensions. This states that we will allow those 3 file types to be uploaded.
- Click the Advanced tab.
- For Org File Name, choose originalfilename. That means the name of the file that was uploaded will be stored in this field.
- For Org Content Type, choose contenttype. The content type for the file that was uploaded will be stored in this field. This is necessary for a field where mutliple file extensions are allowed, and needed when we try to view it later.
- Click Save.
- Save the form.
Testing the form- Run the form by clicking Run Form in the toolbar.
- Enter a name and browse and choose an image.
- Click Save Data and the data will be saved, and the binary image will be stored in the database.
This tutorial is the second of a two-part quick start guide to working with binary data. This is a quick, no-frills walk-through of the how to setup a basic form/report with binary data. In the previous tutorial, a database table and form were created to hold allow uploading of an employee picture. In this tutorial, the images will be displayed in a report.Create a Query- Open Report Builder.
- Click the Switch to Query Builder Mode tab.
- Choose webNetwork Demo Database, enter sa as the User ID and hit Connect.
- Click View/Add Table(s) in the toolbar.
- Expand all the Default + signs and click TABLE.
- Check the box next to EmployeeImages. Note: If this table does not appear, then you need to start with part 1 of this tutorial found in a previous post on this blog.
- Click Add to Query.
- Add all of the fields to the query by clicking on their names.
Create the Report Frontend- Click the Switch to Graphical Designer Mode tab.
- Choose New Report With Template from the toolbar. This option is found under the New Report dropdown.
- Change the Style to Orange and click Save.
- Right click in the originalfilename column and choose Delete Column.
- Right click in the contenttype column and choose Delete Column.
Configure the Binary Display- Right click the yellow employeepicture image and choose Edit Display Properties.
- Click the Binary tab.
- Choose the radio button for Display As Image.
- Choose DB for File Name Src.
- Choose originalfilename as the File Name.
- Choose DB for Content Type Src.
- Choose contenttype for Content Type.
- Click Save.
Test the Report- Save the report and run it. The uploaded images will appear next to the employee names. If you right click and save the image, the original file name will be used.