FileOpen()

edit

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:

  • read
  • readBinary
  • write
  • append

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

edit
myFile = 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