Operate on a file path, or directly on file data (string of bytes typically stored in a variable).
- operation - What operation to perform on the file.
- GetMimeType / GetDataMimeType - Return the MIME type as a string.
- GetType / GetDataType - Get the file type as a human-friendly string.
- GetExtension / GetDataExtension - Get the file extension based on the MIME type, without the preceding dot.
- GetContent - Get the contents of the file, similar to #INCLUDE.
- GetSize - Get the size of the file contents in bytes, similar to #FILESIZE.
- GetMode - Get the file mode in decimal format. Use Perl's or PHP's sprintf( "%o", $DecMode & 07777 ) to convert to octal format.
- GetModificationTime - Get the date and time a file was last modified. If the time can not be determined, which is sometimes the case when accessing via http(s), the current time will be returned. If the file can not be accessed, an error will be logged and nothing is returned.
- Exists - Returns "Exists" if the file exists, otherwise nothing is returned.
- Delete - Deletes a file at the specified path or (FTP or SFTP) URL. If the file can not be deleted, a publish error is produced. Nothing is returned in any case.
- Copy / Move - Copy or Move a file at the specified path or URL to another path or URL. If the file can not be deleted, a publish error is produced. Nothing is returned in any case. Subsequent parameters are:
- Source Path
- Source Username - can be blank if not needed
- Source Password - can be blank if not needed
- Destination Path
- Destination Username - can be blank if not needed
- Destination Password - can be blank if not needed
- Is Binary - copy or move the file as binary data
- Preserve Time and Attributes - keep the same file time (0=new time, 1=keep source time) and mode as the source (0=do not, 1=keep)
- file - A file path or variable containing actual file data (raw bytes). File paths may be specified as:
- Absolute Root - Path from the file repository root ("files" folder in server.conf). Ex. '/www.website.com/htdocs/index.html'.
- Publiation Root - Path from publication's publish path. Ex. './images/test.gif'.
- Relative - Path from current File Blueprint path. Ex. 'attachments/test.pdf'.
- Remote - URL to remote server where FTP, SFTP, HTTP and HTTPS protocols are recognized (username/password notation is not currently recognized). Examples are:
#NEW($FileData)#FILE(GetContent,'/path/to/file')#ENDNEW #NEW($Filename)file.#FILE(GetDataExtension,$FileData)#ENDNEW #NEW($FileURL)#OUTPUT($Filename,$FileData)#ENDNEW <a href="$FileURL">Link</a>