File attachments
Working with Files in Ninox
Ninox allows you to attach files to records. Files stored in the database in this way remain there until they are deleted and can be opened and edited directly in Ninox (provided they are image files or PDFs) and even shared via a public share link, so that anyone with the link can access the file.
Attaching a File
There are several ways to attach a file to a record.
In the attachments tab
By default, every table in a Ninox database has a tab for attachments, identified by the paperclip icon. This tab can be shown or hidden via the table settings. This tab displays, in tile format, all attachments for the record that are not already represented in image fields. Clicking the tile labeled "Add attachment" opens the device’s file explorer, where you can select one or more files; upon confirmation, these files are attached to the record and displayed in the attachments tab.
In an image field
Clicking on an empty image field also opens the file explorer to attach a single file. If you’re using the native app on an iPad, iPhone, or Android device, a context menu opens first instead. From there, you can choose whether to select a file from the device’s storage or from a linked Dropbox cloud storage account, or to take a photo directly. Depending on the option selected, the image is also saved to the device’s storage. After taking the photo, you can scale the image (Large, Medium, or Small) or import it in its original size.
ℹ️ The image field does not contain the file itself, but only a text-based reference to an attachment associated with the record. You can verify this by running the script text(ImageField) in a formula field, for example. This reference consists of the structural record ID (such as "B3" for record 3 of the table with ID "B") and the file name, separated by a slash, e.g., "B3/Invoice.pdf".
If you clear an image field via script (e.g., ImageField := null), the file displayed there is not deleted; only the text reference is removed. From that point on, the respective file appears in the attachments tab instead. Similarly, you can populate an image field with a reference via a script (e.g., ImageField := file(this, "Invoice.pdf")), so that the attachment of the record with this name is no longer displayed in the attachments tab but instead in the image field.
Via Script
The importFile() script function is used to automatically add attachments to a record. The return value is of type "file" and can be assigned directly to an image field upon execution to display the file there. Otherwise, the file appears in the attachments tab.
Editing Files
Ninox allows you to edit file attachments. All files can be renamed at any time. This can be done either by opening the context menu in the top-right corner of an image field or in a tile in the attachments tab and selecting the appropriate option, or by using the renameFile() function. If the file renamed via script is located in an image field, its content is not automatically updated; this must therefore be corrected separately, e.g., using ImageField := file(this, "NewFileName.pdf").
The content of certain file formats can also be edited:
Image Files
Common image formats (PNG, JPG, etc.) can be edited directly in Ninox. To do this, the file must be located in an image field whose "Handle file as" setting is set to "Drawing". Clicking on the populated image field opens an editor rather than a preview.
ℹ️ A signature field is simply an image field whose file handling is automatically set to "Signature" which is a simpler form of the image editor.
PDFs
If you open the context menu of an image field containing a PDF (or that of a tile representing a PDF in the attachments tab), you can select "Open in editor". From that point on, this option replaces the file preview with a PDF editor that allows you to draw on the file, add annotations, and more.
The PDF itself is not edited in this process; instead, a new attachment is created with the same name but the file extension XFDF. This file contains all the modifications, which are simply overlaid visually on top of the PDF when opened in the editor. Using the "Print" option (printer icon in the top-right corner of the editor), you can export the file with all changes combined.
Sharing Files
Files stored in Ninox can be shared so that anyone with the share link - whether a Ninox user or not - can access them. When you click the share link for a PDF or image file, it is displayed in the browser. Files in other formats are simply downloaded.
Manually
The context menu of an image field offers the option “Share this file…”. Clicking this opens a pop-up where you can enable or disable sharing for the file. When enabled, a share link appears that can be copied.
Via Script
The shareFile() function automates sharing; similarly, sharing for an already shared file can be disabled using unshareFile().
Deleting Files
If a file is no longer needed, it can be deleted.
Manually
In the context menu of an image field or a tile in the attachments tab, you can select the "Delete" option to remove an attachment from the database. A confirmation prompt ensures that this does not happen accidentally.
Via Script
The removeFile() function can be used to automatically remove file attachments. However, this does not prompt a confirmation dialog before the file is permanently deleted. If the file is located in an image field, its content is not affected by this operation, so it would still need to be cleared of the reference separately using ImageField := null.
