It’s actually a little bit more complicated that it might seem at first glance. Here’s a little bit of background info:
Internally, the <$browse>
widget creates an HTML <input type="file">
element. This element is handled by the browser’s native code to display a system-provided “folder/file” dialog. After navigating to the desired folder and selecting a file, you press the “open” button. This returns two primary pieces of information for the selected file (or files, if the multiple="multiple"
parameter was specified).
- The “filename.ext” of each selected file
- The base64-encoded file content of each selected file.
TiddlyWIki’s <$browse>
widget then invokes a tm-import-tiddlers
message that triggers the generation and display of the TWCore system $:/Import tiddler interface, which allows you to complete the process of creating tiddlers using the “filename.ext” and base64-encoded file content information returned by the system.
Note that the system does NOT give you the full path to each selected file… just the “filename.ext” portion. This is done by the overly paranoid browser-native code as a security measure in order to avoid exposing information about your directory structure, which might be used by some kind of exploit that is “probing” your system for nefarious purposes.
Thus, while the <$browse>
widget let’s you select local files and create tiddlers with the base64-encoded file contents, you can’t use it to automatically create external file tiddlers that have a _canonical_uri
field with a full path and filename reference.
Note that it is possible to create external file references when using TiddlyWiki invoked via the Nodejs command line. (see https://tiddlywiki.com/#ExternalImages).
However, because of the security limitation described above, this process relies upon a special TWCore template – https://tiddlywiki.com/#%24%3A%2Fcore%2Ftemplates%2Fcanonical-uri-external-image – that manually specifies the desired “base URI” to prepend to the filename.ext provided by the system folder/filename dialog.
In order to change this “base URI” from the default ./images/
prefix, you need to edit the template, as noted in a comment within that template:
Change the `./images/` part to a different base URI. The URI can be relative or absolute.
-e