FileOpen()
Opens an file to read, write, or append.
FileOpen( file=string, mode=string, charset=string, seekable=boolean );
Returns: any
| Argument | Description | Default |
|---|---|---|
|
file
string,
required
|
edit
a file path Alias: path, filepath, source |
|
|
mode
string,
optional
|
edit
Action to perform on the file, including the following:
If you do not specify the mode, Lucee opens the file in read mode. |
read |
|
charset
string,
optional
|
edit
The character set of the file. |
|
|
seekable
boolean,
optional
|
edit
can be used for function fileseek |
Examples
editmyFile = fileOpen("filepath/filename.ext");
writeDump(myfile);
// how to access the underlying resource provider info
f = "ram://demo.txt";
fileWrite(f, "demo");
dump(f.getResource().getResourceProvider().getScheme()); // ram ( i.e. the resource provider type)
See also
- File handling
- FileReadLine()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)