File handling

Provides access to File System Resources, this includes virtual file systems like ram, s3, git, ftp and ssh

Categories

  • S3 Provides access to S3 resources

Functions

  • ContractPath() Does the opposite of the function expandPath(). Tries to match given absolute path to the mappings in the environment. When no mappings match, lucee creates a relative path from the current position.
  • DirectoryCopy() Copies the contents of a directory to a destination directory.
  • DirectoryCreate() Creates new directory for specified path
  • DirectoryDelete() Deltes directory for given path
  • DirectoryExists() Determines whether a directory exists.
  • DirectoryList() Lists the directory and returns the list of files under it as array or query
  • DirectoryRename() Renames given directory
  • ExpandPath() Creates an absolute, platform-appropriate path that is equivalent to the value of relative_path, appended to the base path. This function (despite its name) can accept an absolute or relative path in the relative_path attribute
  • FileAppend() appends the entire content to the specified file.
  • FileClose() Closes an file that is open.
  • FileCopy() Copies the specified on-disk or in-memory source file to the specified destination file.
  • FileDelete() Deletes the specified file on the server.
  • FileExists() Determines whether a file exists
  • FileGetMimeType() Returns the mimetype of the given file
  • FileInfo() returns detailed info about the given file.
  • FileIsEOF() Determines whether Lucee has reached the end of the file while reading it.
  • FileMove() Moves file from source to destination
  • FileOpen() Opens an file to read, write, or append.
  • FileRead() Reads an on-disk or in-memory text file or a file object created with the FileOpen function.
  • FileReadBinary() Reads an on-disk or in-memory binary file (such as an executable or image file) on the server, into a binary object
  • FileReadLine() Reads a line from an file.
  • FileSeek() Shifts the file pointer to the given position. The file must be opened with seekable option
  • FileSetAccessMode() Sets the attributes of an on-disk file on UNIX or Linux. This function does not work with in-memory files.
  • FileSetAttribute() For the given path, sets the file attributes.
  • FileSetLastModified() For the given file, set the last modification date
  • FileSkipBytes() Shifts the file pointer by the given number of bytes.
  • FileTouch() Touches given file, creates the file if not already exists.
  • FileUpload() Uploads file to a directory on the server.
  • FileUploadAll() Uploads file to a directory on the server.
  • FileWrite() If you specify a file path, writes the entire content to the specified file. If you specify a file object, writes text or binary data to the file object.
  • FileWriteLine() Opens up the file (or uses the existing file object) and appends the given line of text
  • GetCanonicalPath() Returns the canonical pathname string based on the given string.
  • GetCurrentTemplatePath() Gets the absolute path of the page that calls this function.
  • GetDirectoryFromPath() Extracts a directory from an absolute path. Returns the absolute path, without the filename.
  • GetFileFromPath() Extracts a filename from an absolute path.
  • GetFileInfo() Retrieves information about file.
  • GetFreeSpace() Returns the number of unallocated bytes in the partition named by this abstract path name.
  • GetProfileSections() Gets all the sections of an initialization file. An initialization file, as a struct whose format is as follows: - Each initialization file section name is a key in the struct - Each list of entries in a section of an initialization file is a value in the struct
  • GetProfileString() Gets an initialization file entry.
  • GetTempDirectory() Returns the full path to the currently assigned temporary directory
  • GetTempFile() Creates a temporary file in a directory whose name starts with (at most) the first three characters of prefix, with an optional extension, default is .tmp.
  • GetTotalSpace() Returns the size of the partition named by this abstract pathname.
  • GetVFSMetaData() Returns metadata about the Virtual File system (VFS)
  • ImageWrite() Writes a image to the specified filename or destination.
  • IsFileObject() Determines whether a value is an file object. True, if the value represents a file object.
  • IsImageFile() Verifies whether an image file is valid.
  • IsZipFile() Verifies whether an zip file is valid.
  • SetProfileString() Sets the value of a profile entry in an initialization file.

Guides

  • <cffileupload> This tag is not supported by Lucee.
  • Define a mapping All about the different mappings in Lucee and how to use them
  • File system - Mappings ## Mapping ## We distinguish 3 different mapping types: - &quot;component&quot; mappings used to map components (similar to a classpath in Java), - &quot;custom tag&quot; mappings used to map custom tags - &quot;regular mappings&quot; for the rest (<cfinclude>, <cffile> .). * Define a mapping * Set a Mapping (regular, component and custom tag mapping) * Define a component Mapping (TODO) * Define a custom tag Mapping (TODO)
  • File System Types Lucee gives you access to a number of resources ### Local Files ### Provides access to the files on the local physical file system. ### Format ### ```lucee [file://] absolute-path ``` Where absolute-path is a valid absolute file name for the local filesystem. Examples ```lucee /home/someuser/somedir c:\program files\some dir c:/program files/some dir file://home/someuser/somedir file://C:/Documents and Settings file:////somehost/someshare/afile
  • File Upload Operation Result Return a struct with the information about the file uploaded operations as the result of cffile action=&amp;quot;upload&amp;quot;/FileUpload()/FileUploadAll(). ### General information ### Key | Description -------------- | ----------------- attemptedServerFile | Name of the file that Lucee attempted to save clientDirectory | Directory of the uploaded file in the client's system clientFile | File name of the uploaded file in the client's system clientFileExt | Extension of the uploaded file in the client's system clientFileName | File name of the uploaded file without extension in the client's system contentSubtype | MIME content subType of the file (i
  • Lucee Resources (Virtual File Systems) Extend your file system with any virtual file system
  • Set a Mapping (regular, component and custom tag mapping) # Set a regular Mapping # Lucee allows to set directory mappings in your Application.cfc, this mappings are only valid for the current request. ```cfs // Application.cfc component { this.mappings['/shop']=getDirectoryFromPath(getCurrentTemplatePath())&amp;&quot;shop&quot;; } ``` We define the mappings as a struct, where the key of the struct is the virtual path

Tags

See also