{fileinfo:url:info}

Description

Returns one piece of metadata about a file, given its URL. The url is usually a file or upload field getter; the second argument names what you want. type and name are read from the URL string alone, so they work anywhere. size and bytesize need the file - a local one in the upload directory, otherwise downloaded - and are empty when it cannot be read; crc, time, mime and ifwebimg work only for an uploaded file: an upload url, or a path in the upload or File Manager directory. Since November 2026 any other file on the server disk gives an empty result (an install not updated since still reads it). link and typesize always give markup, with the size left out when the file cannot be read. With no second argument, or an empty url, the result is empty. The companion command filelink builds a full download link and calls fileinfo internally for the type and size.

Parameters

url required default (empty string)

The file URL to inspect, normally a field getter like _#FILE____ (a file/upload field). A leading-slash path is resolved against the current host. An empty url yields an empty result.

info optional default (empty string)

Which piece of metadata to return. One of the allowed values below. If omitted the result is empty (there is no implicit default). type and name are derived from the URL string alone; crc, time, mime and ifwebimg need an uploaded file - an upload url is mapped to its path, a path in the upload or File Manager directory works too - and return empty for anything else, since November 2026 also for any other file on the server disk. size, bytesize and typesize read such an uploaded file too; any other url is downloaded the same way as by include - an address of the server's private network is refused, and only a successful (2xx) answer counts. link builds a download link through filelink.

Examples

test[{fileinfo:/etc/passwd:time}]
Expected[]
Actual[]
A file on the server disk that was not uploaded is not described: here the system file /etc/passwd, so the result is empty. The same holds for crc, mime and ifwebimg. Since November 2026; an install not updated since still prints the modification time.
virtual[{fileinfo:_#FILE____:link}]
Expectedreport.pdf [pdf - 157 kB] (HTML)
Actual[_  [TXT - ]]
link builds a ready-made download anchor (the same as filelink) with the filename, plus the type and size appended. Its output is HTML markup, so it is illustrative rather than a plain-text test.
test[{fileinfo::type}]
Expected[]
Actual[]
An empty URL yields an empty result regardless of the requested info. This is the safe outcome when a file field is unset.
test[{fileinfo:https://example.org/files/report.pdf:type}]
Expected[pdf]
Actual[pdf]
The type value is the file extension taken from the URL, in lowercase. In real templates the first argument is usually a file-field getter such as _#FILE____ instead of a literal URL.
test[{fileinfo:https://example.org/a/b/report.final.pdf:name}]
Expected[report.final.pdf]
Actual[report.final.pdf]
The name value is the bare filename (basename) from the URL path. Inner dots are kept; only the directory part is removed.
virtual[{fileinfo:_#FILE____:size}]
Expected[157 kB] (depends on the actual file)
Actual[]
size needs the real file, read from disk (uploads) or fetched over HTTP. It prints kB up to 1 MB and MB above. Use bytesize for the raw integer. Empty when the file cannot be read - so this is a runtime-dependent value, shown here illustratively.
virtual[{fileinfo:_#FILE____:mime}]
Expected[image/jpeg] (depends on the actual file)
Actual[]
mime sniffs the content type from an uploaded file (e.g. image/jpeg, application/pdf). Returns empty for any other url or file. Runtime-dependent.
test[{fileinfo:https://example.org/files/photo.JPG?v=3:name}]
Expected[photo.JPG]
Actual[photo.JPG]
Only the path portion of the URL is used, so any ?query is dropped. The original letter case of the name is preserved.
test[{fileinfo:https://example.org/files/report.pdf}]
Expected[]
Actual[]
Without a second argument there is no implicit default, so the result is empty. Always name the info you want (type, name, size, ...).
virtual[{fileinfo:_#FILE____:ifwebimg}]
Expected[https://example.org/files/photo.jpg] (empty when not a web image)
Actual[]
ifwebimg returns the URL unchanged when the file is a browser-displayable image (jpeg, png, gif, webp, avif, svg, bmp), otherwise empty. Handy to guard an _<_img src_=_..._>_ tag. Needs an uploaded file.
virtual[{fileinfo:_#FILE____:typesize}]
Expected[pdf - 157 kB] (HTML badge)
Actual[  [TXT - ]]
typesize combines type and size into a small HTML badge like [pdf - 157 kB]. The size half is empty when the file cannot be read; the output is HTML, hence illustrative.
test[{fileinfo:https://example.org/files/README:type}]
Expected[TXT]
Actual[TXT]
When the filename has no extension, type falls back to the literal TXT.
virtual{filelink:_#FILE____:_#TEXT____:Download#: }
ExpectedDownload: Annual report [pdf - 157 kB] (HTML)
ActualDownload: _#TEXT____  [TXT - ]
The everyday pattern: a download link whose title and trailing badge come from fileinfo. filelink calls fileinfo internally for the type and size, so you rarely call typesize or link directly. Replace _#FILE____ and _#TEXT____ with your slice's file and label fields.