# file

(plugins.file)

## Overview

The file management plugin offers a comprehensive toolkit for managing files and folders both locally and remotely. It supports operations such as creating, reading, modifying, and deleting files while accommodating various formats, including text, binary, and XML. Advanced features like encoding, content streaming, and size management are also integrated to enhance file interactions on both the client and server sides.

Users can perform essential tasks such as `appendToTXTFile`, `writeFile`, and `writeXMLFile`, which allow appending, creating, or modifying files efficiently. The plugin also supports creating temporary files through `createTempFile` and managing folder contents with `getFolderContents`. Folder operations include recursive copying using `copyFolder` and deletion with `deleteFolder`, all while providing detailed file attributes such as modification dates via `getModificationDate` and sizes with `getFileSize`. Flexible filtering options enable targeted retrieval of folder contents, enhancing workflow precision.

For interactive use, the plugin facilitates file selection dialogs through `showFileOpenDialog`, supporting multiselect and file type filters, with customizable callback functionality. Large files can be streamed directly to the browser using `streamFile` without consuming excessive memory, ensuring optimal performance for downloads or inline viewing. Temporary file handling via `trackFileForDeletion` automates cleanup processes upon solution closure, contributing to resource efficiency.

## Properties

| Property                                 | Description                                                                                                                               |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `servoy.FileServerService.defaultFolder` | Set the default folder path (absolute path on the server) to save files sent by clients (will default to user.home/.servoy/uploads/UUID/) |

## **Returned Types**

[JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile),

## Methods Summarized

| Type                                                                                    | Name                                                                                                                                                                                          | Summary                                                                                                                                                                                                                      |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [appendToTXTFile(file, text)](#appendtotxtfile-file-text)                                                                                                                                     | Appends a string given in parameter to a file, using default platform encoding.                                                                                                                                              |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [appendToTXTFile(file, text, encoding)](#appendtotxtfile-file-text-encoding)                                                                                                                  | Appends a string given in parameter to a file, using the specified encoding.                                                                                                                                                 |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [appendToTXTFile(file, text)](#appendtotxtfile-file-text)                                                                                                                                     | Appends a string given in parameter to a file, using default platform encoding.                                                                                                                                              |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [appendToTXTFile(file, text, encoding)](#appendtotxtfile-file-text-encoding)                                                                                                                  | Appends a string given in parameter to a file, using the specified encoding.                                                                                                                                                 |
| [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) | [convertToJSFile(file)](#converttojsfile-file)                                                                                                                                                | Returns a JSFile instance corresponding to an alternative representation of a file (for example a string).                                                                                                                   |
| [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) | [convertToRemoteJSFile(path)](#converttoremotejsfile-path)                                                                                                                                    | Convenience return to get a JSFile representation of a server file based on its path.                                                                                                                                        |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [copyFile(source, destination)](#copyfile-source-destination)                                                                                                                                 | Copies the source file to the destination file.                                                                                                                                                                              |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [copyFolder(source, destination)](#copyfolder-source-destination)                                                                                                                             | Copies the sourcefolder to the destination folder, recursively.                                                                                                                                                              |
| [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) | [createFile(targetFile)](#createfile-targetfile)                                                                                                                                              | Creates a JSFile instance.                                                                                                                                                                                                   |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [createFolder(destination)](#createfolder-destination)                                                                                                                                        | Creates the folder by the given pathname, including any necessary but nonexistent parent folders.                                                                                                                            |
| [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) | [createTempFile(prefix, suffix)](#createtempfile-prefix-suffix)                                                                                                                               | Creates a temporary file on disk.                                                                                                                                                                                            |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [deleteFile(destination)](#deletefile-destination)                                                                                                                                            | Removes a file from disk.                                                                                                                                                                                                    |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [deleteFolder(destination, showWarning)](#deletefolder-destination-showwarning)                                                                                                               | Deletes a folder from disk recursively.                                                                                                                                                                                      |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [getDefaultUploadLocation()](#getdefaultuploadlocation)                                                                                                                                       | Returns the default upload location path of the server.                                                                                                                                                                      |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getDiskList()](#getdisklist)                                                                                                                                                                 | Returns an Array of JSFile instances correponding to the file system root folders.                                                                                                                                           |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)            | [getFileSize(fileOrPath)](#getfilesize-fileorpath)                                                                                                                                            | Returns the size of the specified file.                                                                                                                                                                                      |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder)](#getfoldercontents-targetfolder)                                                                                                                            | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter)](#getfoldercontents-targetfolder-filefilter)                                                                                                     | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption)](#getfoldercontents-targetfolder-filefilter-fileoption)                                                                              | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption, visibleOption)](#getfoldercontents-targetfolder-filefilter-fileoption-visibleoption)                                                 | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)](#getfoldercontents-targetfolder-filefilter-fileoption-visibleoption-lockedoption)                      | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder)](#getfoldercontents-targetfolder)                                                                                                                            | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter)](#getfoldercontents-targetfolder-filefilter)                                                                                                     | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption)](#getfoldercontents-targetfolder-filefilter-fileoption)                                                                              | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption, visibleOption)](#getfoldercontents-targetfolder-filefilter-fileoption-visibleoption)                                                 | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)](#getfoldercontents-targetfolder-filefilter-fileoption-visibleoption-lockedoption)                      | Returns an array of JSFile instances corresponding to content of the specified folder.                                                                                                                                       |
| [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) | [getHomeFolder()](#gethomefolder)                                                                                                                                                             | Returns a JSFile instance corresponding to the home folder of the logged in used.                                                                                                                                            |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)            | [getMaxUploadFileSize()](#getmaxuploadfilesize)                                                                                                                                               | Returns the maximum allowed file size for uploads in KB.                                                                                                                                                                     |
| [Date](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/date)                | [getModificationDate(fileOrPath)](#getmodificationdate-fileorpath)                                                                                                                            | Returns the modification date of a file.                                                                                                                                                                                     |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder)](#getremotefoldercontents-targetfolder)                                                                                                                | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter)](#getremotefoldercontents-targetfolder-filefilter)                                                                                         | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption)                                                                  | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption-visibleoption)                                     | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption-visibleoption-lockedoption)          | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder)](#getremotefoldercontents-targetfolder)                                                                                                                | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter)](#getremotefoldercontents-targetfolder-filefilter)                                                                                         | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption)                                                                  | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption-visibleoption)                                     | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)](#getremotefoldercontents-targetfolder-filefilter-fileoption-visibleoption-lockedoption)          | Returns an array of JSFile instances corresponding to content of the specified folder on the server side.                                                                                                                    |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [moveFile(source, destination)](#movefile-source-destination)                                                                                                                                 | Moves the file from the source to the destination place.                                                                                                                                                                     |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [openFile(file)](#openfile-file)                                                                                                                                                              | Opens the given local file.                                                                                                                                                                                                  |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [openFile(file, webClientTarget, webClientTargetOptions)](#openfile-file-webclienttarget-webclienttargetoptions)                                                                              | Opens the given local file.                                                                                                                                                                                                  |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [openFile(fileName, data, mimeType)](#openfile-filename-data-mimetype)                                                                                                                        | Opens the given data as a file.                                                                                                                                                                                              |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [openFile(fileName, data, mimeType, webClientTarget, webClientTargetOptions)](#openfile-filename-data-mimetype-webclienttarget-webclienttargetoptions)                                        | Opens the given data as a file.                                                                                                                                                                                              |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [readFile()](#readfile)                                                                                                                                                                       | Reads all or part of the content from a binary file.                                                                                                                                                                         |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [readFile(file)](#readfile-file)                                                                                                                                                              | Reads all or part of the content from a binary file.                                                                                                                                                                         |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [readFile(file, size)](#readfile-file-size)                                                                                                                                                   | Reads all or part of the content from a binary file.                                                                                                                                                                         |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [readFile(file)](#readfile-file)                                                                                                                                                              | Reads all or part of the content from a binary file.                                                                                                                                                                         |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)              | [readFile(file, size)](#readfile-file-size)                                                                                                                                                   | Reads all or part of the content from a binary file.                                                                                                                                                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [readTXTFile()](#readtxtfile)                                                                                                                                                                 | Read all content from a text file.                                                                                                                                                                                           |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [readTXTFile(file)](#readtxtfile-file)                                                                                                                                                        | Read all content from a text file.                                                                                                                                                                                           |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [readTXTFile(file, charsetname)](#readtxtfile-file-charsetname)                                                                                                                               | Read all content from a text file.                                                                                                                                                                                           |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [readTXTFile(file)](#readtxtfile-file)                                                                                                                                                        | Read all content from a text file.                                                                                                                                                                                           |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)            | [readTXTFile(file, charsetname)](#readtxtfile-file-charsetname)                                                                                                                               | Read all content from a text file.                                                                                                                                                                                           |
| void                                                                                    | [setMaxUploadFileSize(size)](#setmaxuploadfilesize-size)                                                                                                                                      | Sets the maximum allowed file size for uploads in KB.                                                                                                                                                                        |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-multiselect-filter-callbackfunction)              | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction, title)](#showfileopendialog-selectionmode-startdirectory-multiselect-filter-callbackfunction-title) | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-multiselect-callbackfunction)                             | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-callbackfunction)                                                      | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-multiselect-filter-callbackfunction)              | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction, title)](#showfileopendialog-selectionmode-startdirectory-multiselect-filter-callbackfunction-title) | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, multiselect, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-multiselect-callbackfunction)                             | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, startDirectory, callbackfunction)](#showfileopendialog-selectionmode-startdirectory-callbackfunction)                                                      | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(selectionMode, callbackfunction)](#showfileopendialog-selectionmode-callbackfunction)                                                                                     | Shows a file open dialog.                                                                                                                                                                                                    |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)            | [showFileOpenDialog(callbackfunction)](#showfileopendialog-callbackfunction)                                                                                                                  | Shows a file open dialog.                                                                                                                                                                                                    |
| void                                                                                    | [streamFile(file)](#streamfile-file)                                                                                                                                                          | Stream the given file(path) to the browser with content-disposition:attachment This will not load in the file fully into memory but only stream it right from disk.                                                          |
| void                                                                                    | [streamFile(file, contentDisposition)](#streamfile-file-contentdisposition)                                                                                                                   | String the given file(path) to the browser you can provide the content disposition how this should be send (inline or as an attachment) This will not load in the file fully into memory but only stream it right from disk. |
| void                                                                                    | [streamFile(file, contentDisposition, browserTarget)](#streamfile-file-contentdisposition-browsertarget)                                                                                      | String the given file(path) to the browser you can provide the content disposition how this should be send (inline or as an attachment) This will not load in the file fully into memory but only stream it right from disk. |
| void                                                                                    | [trackFileForDeletion(file)](#trackfilefordeletion-file)                                                                                                                                      | If the client's solution is closed, the file given to this method will be deleted.                                                                                                                                           |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeFile(file, data)](#writefile-file-data)                                                                                                                                                 | Writes the given file to disk.                                                                                                                                                                                               |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeFile(file, data, mimeType)](#writefile-file-data-mimetype)                                                                                                                              | Writes the given file to disk.                                                                                                                                                                                               |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeFile(file, data)](#writefile-file-data)                                                                                                                                                 | Writes the given file to disk.                                                                                                                                                                                               |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeFile(file, data, mimeType)](#writefile-file-data-mimetype)                                                                                                                              | Writes the given file to disk.                                                                                                                                                                                               |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data)](#writetxtfile-file-text_data)                                                                                                                                | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data, charsetname)](#writetxtfile-file-text_data-charsetname)                                                                                                       | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data, charsetname, mimeType)](#writetxtfile-file-text_data-charsetname-mimetype)                                                                                    | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data)](#writetxtfile-file-text_data)                                                                                                                                | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data, charsetname)](#writetxtfile-file-text_data-charsetname)                                                                                                       | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeTXTFile(file, text\_data, charsetname, mimeType)](#writetxtfile-file-text_data-charsetname-mimetype)                                                                                    | Writes data into a text file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeXMLFile(file, xml\_data)](#writexmlfile-file-xml_data)                                                                                                                                  | Writes data into an XML file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeXMLFile(file, xml\_data, encoding)](#writexmlfile-file-xml_data-encoding)                                                                                                               | Writes data into an XML file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeXMLFile(file, xml\_data)](#writexmlfile-file-xml_data)                                                                                                                                  | Writes data into an XML file.                                                                                                                                                                                                |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)          | [writeXMLFile(file, xml\_data, encoding)](#writexmlfile-file-xml_data-encoding)                                                                                                               | Writes data into an XML file.                                                                                                                                                                                                |

## Methods Detailed

### appendToTXTFile(file, text)

Appends a string given in parameter to a file, using default platform encoding.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text** the text to append to the file

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if appending worked

**Sample**

```js
// append some text to a text file:
	var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
```

### appendToTXTFile(file, text, encoding)

Appends a string given in parameter to a file, using the specified encoding.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text** the text to append to the file
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **encoding** the encoding to use

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if appending worked

**Sample**

```js
// append some text to a text file:
	var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
```

### appendToTXTFile(file, text)

Appends a string given in parameter to a file, using default platform encoding.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text** the text to append to the file

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if appending worked

**Sample**

```js
// append some text to a text file:
	var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
```

### appendToTXTFile(file, text, encoding)

Appends a string given in parameter to a file, using the specified encoding.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text** the text to append to the file
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **encoding** the encoding to use

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text is successfully appended to the file located at the specified file path using the given encoding; false otherwise.

**Sample**

```js
// append some text to a text file:
	var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
```

### convertToJSFile(file)

Returns a JSFile instance corresponding to an alternative representation of a file (for example a string).

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **file** ;

**Returns:** [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) a JSFile instance corresponding to the given file representation, or null if conversion is not possible.

**Sample**

```js
var f = plugins.file.convertToJSFile("story.txt");
if (f.canRead())
	application.output("File can be read.");
```

### convertToRemoteJSFile(path)

Convenience return to get a JSFile representation of a server file based on its path.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **path** the path representing a file on the server (should start with "/")

**Returns:** [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) the JSFile

**Sample**

```js
var f = plugins.file.convertToRemoteJSFile('/story.txt');
if (f && f.canRead())
	application.output('File can be read.');
```

### copyFile(source, destination)

Copies the source file to the destination file. Returns true if the copy succeeds, false if any error occurs.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **source** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the file was copied successfully; false otherwise.

**Sample**

```js
// Copy based on file names.
if (!plugins.file.copyFile("story.txt", "story.txt.copy"))
	application.output("Copy failed.");
// Copy based on JSFile instances.
var f = plugins.file.createFile("story.txt");
var fcopy = plugins.file.createFile("story.txt.copy2");
if (!plugins.file.copyFile(f, fcopy))
	application.output("Copy failed.");
```

### copyFolder(source, destination)

Copies the sourcefolder to the destination folder, recursively. Returns true if the copy succeeds, false if any error occurs.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **source** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the folder was copied successfully; false otherwise.

**Sample**

```js
// Copy folder based on names.
if (!plugins.file.copyFolder("stories", "stories_copy"))
	application.output("Folder copy failed.");
// Copy folder based on JSFile instances.
var d = plugins.file.createFile("stories");
var dcopy = plugins.file.createFile("stories_copy_2");
if (!plugins.file.copyFolder(d, dcopy))
	application.output("Folder copy failed.");
```

### createFile(targetFile)

Creates a JSFile instance. Does not create the file on disk.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **targetFile** ;

**Returns:** [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) a JSFile instance representing the specified target file.

**Sample**

```js
// Create the JSFile instance based on the file name.
var f = plugins.file.createFile("newfile.txt");
// Create the file on disk.
if (!f.createNewFile())
	application.output("The file could not be created.");
```

### createFolder(destination)

Creates the folder by the given pathname, including any necessary but nonexistent parent folders.\
Note that if this operation fails it may have succeeded in creating some of the necessary parent folders.\
Will return true if it could make this folder or if the folder did already exist.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the folder was created successfully or already exists; false otherwise.

**Sample**

```js
var d = plugins.file.convertToJSFile("newfolder");
if (!plugins.file.createFolder(d))
	application.output("Folder could not be created.");
```

### createTempFile(prefix, suffix)

Creates a temporary file on disk. A prefix and an extension are specified and they will be part of the file name.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **prefix** ;
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **suffix** ;

**Returns:** [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) a JSFile instance representing the created temporary file.

**Sample**

```js
var tempFile = plugins.file.createTempFile('myfile','.txt');
application.output('Temporary file created as: ' + tempFile.getAbsolutePath());
plugins.file.writeTXTFile(tempFile, 'abcdefg');
```

### deleteFile(destination)

Removes a file from disk. Returns true on success, false otherwise.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the file was successfully deleted; false otherwise.

**Sample**

```js
if (plugins.file.deleteFile('story.txt'))
	application.output('File deleted.');

//In case the file to delete is a remote file:
var file = plugins.file.convertToRemoteJSFile('/story.txt');
plugins.file.deleteFile(file);
```

### deleteFolder(destination, showWarning)

Deletes a folder from disk recursively. Returns true on success, false otherwise. If the second parameter is set to true, then a warning will be issued to the user before actually removing the folder.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **showWarning** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the file was successfully deleted; false otherwise.

**Sample**

```js
if (plugins.file.deleteFolder('stories', true))
	application.output('Folder deleted.');

//In case the file to delete is a remote folder:
plugins.file.deleteFolder(plugins.file.convertToRemoteJSFile('/stories'), true);
```

### getDefaultUploadLocation()

Returns the default upload location path of the server.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the location as canonical path

**Sample**

```js
// get the (server-side) default upload location path:
var serverPath = plugins.file.getDefaultUploadLocation();
```

### getDiskList()

Returns an Array of JSFile instances correponding to the file system root folders.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the root folders of the file system.

**Sample**

```js
var roots = plugins.file.getDiskList();
for (var i = 0; i < roots.length; i++)
	application.output(roots[i].getAbsolutePath());
```

### getFileSize(fileOrPath)

Returns the size of the specified file.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileOrPath** can be a (remote) JSFile or a local file path

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) the size of the specified file in bytes, or -1 if the file is invalid.

**Sample**

```js
var f = plugins.file.convertToJSFile('story.txt');
application.output('file size: ' + plugins.file.getFileSize(f));

//In case the file is remote, located on the server side inside the default upload folder:
var f = plugins.file.convertToRemoteJSFile('/story.txt');
application.output('file size: ' + plugins.file.getFileSize(f));
```

### getFolderContents(targetFolder)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** JSFile object.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption, visibleOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **lockedOption** 1=locked, 2=nonlocked

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** File path.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** File path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** File path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption, visibleOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** File path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)

Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** File path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **lockedOption** 1=locked, 2=nonlocked

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) an array of JSFile instances representing the contents of the specified folder that match the given filters.

**Sample**

```js
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
```

### getHomeFolder()

Returns a JSFile instance corresponding to the home folder of the logged in used.

**Returns:** [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) a JSFile instance representing the home folder of the currently logged-in user.

**Sample**

```js
var d = plugins.file.getHomeFolder();
application.output('home folder: ' + d.getAbsolutePath());
```

### getMaxUploadFileSize()

Returns the maximum allowed file size for uploads in KB.\
Defaults to servoy.webclient.maxuploadsize parameter from Admin page\
If this return 0 then this means there is no maximum set.

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) the maximum file size in KB

**Sample**

```js
// get the current maximum file size
var maxSize = plugins.file.getMaxUploadFileSize();
application.output("Maximum file size: " + maxSize + " KB");
```

### getModificationDate(fileOrPath)

Returns the modification date of a file.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileOrPath** can be a (remote) JSFile or a local file path

**Returns:** [Date](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/date) the last modification date of the specified file, or null if the file is invalid.

**Sample**

```js
var f = plugins.file.convertToJSFile('story.txt');
application.output('last changed: ' + plugins.file.getModificationDate(f));

//In case the file is remote, located on the server side inside the default upload folder:
var f = plugins.file.convertToRemoteJSFile('/story.txt');
application.output('file size: ' + plugins.file.getModificationDate(f));
```

### getRemoteFolderContents(targetFolder)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents(plugins.file.convertToRemoteJSFile('/'), '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** Folder as JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents(plugins.file.convertToRemoteJSFile('/'), '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** Folder as JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents(plugins.file.convertToRemoteJSFile('/'), '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** Folder as JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents(plugins.file.convertToRemoteJSFile('/'), '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **targetFolder** Folder as JSFile object.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **lockedOption** 1=locked, 2=nonlocked

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents(plugins.file.convertToRemoteJSFile('/'), '.txt');
```

### getRemoteFolderContents(targetFolder)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents('/', '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** Folder path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents('/', '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** Folder path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents('/', '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** Folder path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents('/', '.txt');
```

### getRemoteFolderContents(targetFolder, fileFilter, fileOption, visibleOption, lockedOption)

Returns an array of JSFile instances corresponding to content of the specified folder on the server side. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **targetFolder** Folder path.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **fileFilter** Filter or array of filters for files in folder.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fileOption** 1=files, 2=dirs
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **visibleOption** 1=visible, 2=nonvisible
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **lockedOption** 1=locked, 2=nonlocked

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the array of file names

**Sample**

```js
// retrieves an array of files located on the server side inside the default upload folder:
var files = plugins.file.getRemoteFolderContents('/', '.txt');
```

### moveFile(source, destination)

Moves the file from the source to the destination place. Returns true on success, false otherwise.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **source** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **destination** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the file was moved successfully; false otherwise.

**Sample**

```js
// Move file based on names.
if (!plugins.file.moveFile('story.txt','story.txt.new'))
	application.output('File move failed.');
// Move file based on JSFile instances.
var f = plugins.file.convertToJSFile('story.txt.new');
var fmoved = plugins.file.convertToJSFile('story.txt');
if (!plugins.file.moveFile(f, fmoved))
	application.output('File move back failed.');
```

### openFile(file)

Opens the given local file.

The (server local) file will open inside the browser - if supported (sent using "Content-disposition: inline" HTTP header).

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** the local file to open. The file should exist and be accessible.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) success status of the open operation

**Sample**

```js
var myPDF = plugins.file.createFile('my.pdf');
 myPDF.setBytes(data, true)
	plugins.file.openFile(myPDF);
```

### openFile(file, webClientTarget, webClientTargetOptions)

Opens the given local file.

The (server local) file will open inside the browser - if supported (sent using "Content-disposition: inline" HTTP header).

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** the local file to open. The file should exist and be accessible.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **webClientTarget** Target frame or named dialog/window. For example "\_self" to open in the same browser window, "\_blank" for another browser window. By default "\_blank" is used.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **webClientTargetOptions** window options used when a new browser window is to be shown; see browser JS 'window\.open(...)' documentation.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) success status of the open operation

**Sample**

```js
var myPDF = plugins.file.createFile('my.pdf');
 myPDF.setBytes(data, true)
	plugins.file.openFile(myPDF, "_self", null); // show in the same browser window
```

### openFile(fileName, data, mimeType)

Opens the given data as a file.

The data will open as a file inside the browser - if supported (sent using "Content-disposition: inline" HTTP header).

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **fileName** the name of the file that should open with the given data. Can be null.
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the file's binary content.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** can be left null, and is used for webclient only. Specify one of any valid mime types:\
  <https://developer.mozilla.org/en-US/docs/Properly\\_Configuring\\_Server\\_MIME\\_Types\\>
  <http://www.iana.org/assignments/media-types/media-types.xhtml\\>
  <http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7>

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) success status of the open operation

**Sample**

```js
// read or generate pdf file bytes
var bytes = plugins.file.readFile("c:/ExportedPdfs/13542.pdf");

// mimeType variable can be left null
var mimeType = 'application/pdf'

if (!plugins.file.openFile("MonthlyStatistics.pdf", bytes, mimeType))
	application.output('Failed to open the file.');
```

### openFile(fileName, data, mimeType, webClientTarget, webClientTargetOptions)

Opens the given data as a file.

The data will open as a file inside the browser - if supported (sent using "Content-disposition: inline" HTTP header).

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **fileName** the name of the file that should open with the given data. Can be null.
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the file's binary content.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** can be left null, and is used for webclient only. Specify one of any valid mime types:\
  <https://developer.mozilla.org/en-US/docs/Properly\\_Configuring\\_Server\\_MIME\\_Types\\>
  <http://www.iana.org/assignments/media-types/media-types.xhtml\\>
  <http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7>
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **webClientTarget** Target frame or named dialog/window. For example "\_self" to open in the same browser window, "\_blank" for another browser window. By default "\_blank" is used.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **webClientTargetOptions** window options used when a new browser window is to be shown; see browser JS 'window\.open(...)' documentation.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) success status of the open operation

**Sample**

```js
// read or generate pdf file bytes
var bytes = plugins.file.readFile("c:/ExportedPdfs/13542.pdf");

// mimeType variable can be left null
var mimeType = 'application/pdf'

if (!plugins.file.openFile("MonthlyStatistics.pdf", bytes, mimeType, "_self", null))
	application.output('Failed to open the file.');
```

### readFile()

Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled only for a JSFile argument)

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the content of the selected binary file as a byte array, or null if no file is selected or an error occurs.

**Sample**

```js
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
```

### readFile(file)

Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled only for a JSFile argument)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the content of the specified binary file as a byte array, or null if the file cannot be read or an error occurs.

**Sample**

```js
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
```

### readFile(file, size)

Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled only for a JSFile argument)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **size** Number of bytes to read.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a byte array containing up to the specified number of bytes from the given binary file, or null if the file cannot be read or an error occurs.

**Sample**

```js
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
```

### readFile(file)

Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled only for a JSFile argument)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) the content of the binary file located at the specified file path as a byte array, or null if the file cannot be read or an error occurs.

**Sample**

```js
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
```

### readFile(file, size)

Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled only for a JSFile argument)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **size** Number of bytes to read.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a byte array containing up to the specified number of bytes from the binary file located at the given file path, or null if the file cannot be read or an error occurs.

**Sample**

```js
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
```

### readTXTFile()

Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled only for a JSFile argument)

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the content of the selected text file as a String, or null if no file was selected.

**Sample**

```js
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
```

### readTXTFile(file)

Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled only for a JSFile argument)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the content of the specified file path as a String, or null if the file is invalid.

**Sample**

```js
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
```

### readTXTFile(file, charsetname)

Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled only for a JSFile argument)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the content of the specified file as a String, or null if the file is invalid.

**Sample**

```js
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
```

### readTXTFile(file)

Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled only for a JSFile argument)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the content of the specified file path as a String, or null if the file is invalid.

**Sample**

```js
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
```

### readTXTFile(file, charsetname)

Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled only for a JSFile argument)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) the content of the specified file path as a String, or null if the file is invalid.

**Sample**

```js
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
```

### setMaxUploadFileSize(size)

Sets the maximum allowed file size for uploads in KB.\
Defaults to servoy.webclient.maxuploadsize parameter from Admin page if the value is set to 0;

This sets the maximum file size uploads for the file plugin showFileOpenDialog but also for the file upload component.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **size** the maximum file size in KB;\
  &#x20;       0 tis will use the default size from the admin page (servoy.webclient.maxuploadsize)\
  &#x20;       \> 0 max file size for upload (kb) overwriting the admin page value.

**Returns:** void

**Sample**

```js
// set maximum file size to 10 MB
plugins.file.setMaxUploadFileSize(10000);

// remove size limit, fallback to the admin page property
plugins.file.setMaxUploadFileSize(0);
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **startDirectory** JSFile instance of default folder,null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **filter** A filter or array of filters on the folder files.
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction, title)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **startDirectory** JSFile instance of default folder, null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **filter** A filter or array of filters on the folder files.
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **title** The tile of the dialog

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **startDirectory** JSFile instance of default folder,null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **startDirectory** JSFile instance of default folder,null=default/previous
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **startDirectory** Path to default folder,null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **filter** A filter or array of filters on the folder files.
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, filter, callbackfunction, title)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **startDirectory** Path to default folder, null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **filter** A filter or array of filters on the folder files.
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **title** The tile of the dialog

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, multiselect, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **startDirectory** Path to default folder,null=default/previous
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **multiselect** true/false
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, startDirectory, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **startDirectory** Path to default folder,null=default/previous
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(selectionMode, callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **selectionMode** 0=both,1=Files,2=Dirs
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### showFileOpenDialog(callbackfunction)

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callbackfunction** A function that takes the (JSFile) array of the selected files as first argument

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) a JSFile or an array of JSFiles selected by the user, or null if no file was selected.

**Sample**

```js
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
/** @type {JSFile} */
var f = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF", "jpg", "gif"));
application.output('File: ' + f.getName());
application.output('is dir: ' + f.isDirectory());
application.output('is file: ' + f.isFile());
application.output('path: ' + f.getAbsolutePath());

// This allows mutliple selection of files, using previous dir and the same filter as above. This also casts the result to the JSFile type using JSDoc.
// if filters are specified, "all file" filter will not show up unless "*" filter is present
/** @type {JSFile[]} */
var files = plugins.file.showFileOpenDialog(1, null, true, new Array("JPG and GIF", "jpg", "gif", "*"));
for (var i = 0; i < files.length; i++)
{
	 application.output('File: ' + files[i].getName());
	 application.output('content type: ' + files[i].getContentType());
	 application.output('last modified: ' + files[i].lastModified());
	 application.output('size: ' + files[i].size());
}
//for the web and NG you have to give a callback function that has a JSFile array as its first argument (also works in smart), only multi select and the title are used in the webclient, others are ignored
plugins.file.showFileOpenDialog(null,null,false,new Array("JPG and GIF", "jpg", "gif"),mycallbackfunction,'Select some nice files')

When handling big files please look at the admin page properties: "servoy.ng_web_client.tempfile.threshold" and "servoy.ng_web_client.temp.uploadir", so that big files are mapped to temp files and saved to a good temp dir
so that in the callback method you can try to rename the temp generated file to something on the filesystem with a specific name. This way there is no need to stream anything again on the server side
(or access the bytes which will load the big file completely in memory)
```

### streamFile(file)

Stream the given file(path) to the browser with content-disposition:attachment\
This will not load in the file fully into memory but only stream it right from disk.\
This can be any filepath on the server, but only the simple file name is exposed as the content disposition header filename.\
This will throw an exception if anything goes wrong, like the given file is not valid/found.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **file** A path string, JSFile or RemoteFile

**Returns:** void

### streamFile(file, contentDisposition)

String the given file(path) to the browser you can provide the content disposition how this should be send (inline or as an attachment)\
This will not load in the file fully into memory but only stream it right from disk.\
This can be any filepath on the server, but only the simple file name is exposed.\
This will throw an exception if anything goes wrong, like the given file is not valid/found.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **file** A path string, JSFile or RemoteFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **contentDisposition** can be 'inline' or 'attachment'

**Returns:** void

### streamFile(file, contentDisposition, browserTarget)

String the given file(path) to the browser you can provide the content disposition how this should be send (inline or as an attachment)\
This will not load in the file fully into memory but only stream it right from disk.\
This can be any filepath on the server, but only the simple file name is exposed.\
This will throw an exception if anything goes wrong, like the given file is not valid/found.\
Give the browser target if you want to open the file inside another tab, most usefull in 'inline' content disposition mode.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **file** A path string, JSFile or RemoteFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **contentDisposition** can be 'inline' or 'attachment'
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **browserTarget** \_blank or a specific name to open this in a differnt tab (really only usefull in inline mode)

**Returns:** void

### trackFileForDeletion(file)

If the client's solution is closed, the file given to this method will be deleted.\
This can be a remote or local file.

This can be used to have temp files within a client that will be cleaned up when the solution is closed.\
So they live as long as the client has its solution open.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** the file to track

**Returns:** void

**Sample**

```js
var file = plugins.file.createFile("newfile.txt");
plugins.file.writeTXTFile(file, "some data");
plugins.file.trackFileForDeletionfile(file);
```

### writeFile(file, data)

Writes the given file to disk.

If "file" is a String (like 'mypdffile.pdf' to hint the browser what it is) the user will get\
prompted by the browser to save the file (sent using "Content-disposition: attachment" HTTP header). If it is a JSFile instance\
in this case it will be saved as a file on the server.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the data to be written

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the binary data was successfully written to the file; false otherwise

**Sample**

```js
/**@type {Array<byte>}*/
var bytes = new Array();
for (var i=0; i<1024; i++)
	bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
	application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: https://developer.mozilla.org/en-US/docs/Properly_Configuring_Server_MIME_Types
var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
	application.output('Failed to write the file.');
```

### writeFile(file, data, mimeType)

Writes the given file to disk.

If "file" is a String (like 'mypdffile.pdf' to hint the browser what it is) the user will get\
prompted by the browser to save the file (sent using "Content-disposition: attachment" HTTP header). If it is a JSFile instance\
in this case it will be saved as a file on the server.

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the data to be written
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** the mime type (used in Web-Client)

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the binary data was successfully written to the file; false otherwise.

**Sample**

```js
/**@type {Array<byte>}*/
var bytes = new Array();
for (var i=0; i<1024; i++)
	bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
	application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: https://developer.mozilla.org/en-US/docs/Properly_Configuring_Server_MIME_Types
var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
	application.output('Failed to write the file.');
```

### writeFile(file, data)

Writes the given file to disk.

If "file" is a String (like 'mypdffile.pdf' to hint the browser what it is) the user will get\
prompted by the browser to save the file (sent using "Content-disposition: attachment" HTTP header). If it is a JSFile instance\
in this case it will be saved as a file on the server.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the data to be written

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the binary data was successfully written to the file path; false otherwise.

**Sample**

```js
/**@type {Array<byte>}*/
var bytes = new Array();
for (var i=0; i<1024; i++)
	bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
	application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: https://developer.mozilla.org/en-US/docs/Properly_Configuring_Server_MIME_Types
var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
	application.output('Failed to write the file.');
```

### writeFile(file, data, mimeType)

Writes the given file to disk.

If "file" is a String (like 'mypdffile.pdf' to hint the browser what it is) the user will get\
prompted by the browser to save the file (sent using "Content-disposition: attachment" HTTP header). If it is a JSFile instance\
in this case it will be saved as a file on the server.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **data** the data to be written
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** the mime type (used in Web-Client)

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the binary data was successfully written to the file path; false otherwise.

**Sample**

```js
/**@type {Array<byte>}*/
var bytes = new Array();
for (var i=0; i<1024; i++)
	bytes[i] = i % 100;
var f = plugins.file.convertToJSFile('bin.dat');
if (!plugins.file.writeFile(f, bytes))
	application.output('Failed to write the file.');
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: https://developer.mozilla.org/en-US/docs/Properly_Configuring_Server_MIME_Types
var mimeType = 'application/vnd.ms-excel'
if (!plugins.file.writeFile(f, bytes, mimeType))
	application.output('Failed to write the file.');
```

### writeTXTFile(file, text\_data)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the file; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeTXTFile(file, text\_data, charsetname)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the specified file; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeTXTFile(file, text\_data, charsetname, mimeType)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** Content type (used only on web).

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the specified file; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeTXTFile(file, text\_data)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** The file path.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the specified file path; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeTXTFile(file, text\_data, charsetname)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** The file path.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the specified file path; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeTXTFile(file, text\_data, charsetname, mimeType)

Writes data into a text file. (Web Enabled: file parameter can be a string 'mytextfile.txt' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** The file path.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **text\_data** Text to be written.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **charsetname** Charset name.
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **mimeType** Content type (used only on web).

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the text data was successfully written to the specified file path; false otherwise.

**Sample**

```js
var fileNameSuggestion = 'myspecialexport.tab'
var textData = 'load of data...'
var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
if (!success) application.output('Could not write file.');
// For file-encoding parameter options (default OS encoding is used), http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
```

### writeXMLFile(file, xml\_data)

Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled: file parameter can be a string 'myxmlfile.xml' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **xml\_data** the xml data to write

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the XML data was successfully written to the specified file; false otherwise.

**Sample**

```js
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
```

### writeXMLFile(file, xml\_data, encoding)

Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled: file parameter can be a string 'myxmlfile.xml' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [JSFile](https://docs.servoy.com/reference/servoyextensions/server-plugins/file/jsfile) **file** a local JSFile
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **xml\_data** the xml data to write
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **encoding** the specified encoding

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the XML data was successfully written to the file; false otherwise.

**Sample**

```js
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
```

### writeXMLFile(file, xml\_data)

Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled: file parameter can be a string 'myxmlfile.xml' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **xml\_data** the xml data to write

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the XML data was successfully written to the specified file path; false otherwise.

**Sample**

```js
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
```

### writeXMLFile(file, xml\_data, encoding)

Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled: file parameter can be a string 'myxmlfile.xml' to hint the browser what it is, if it is a JSFile instance it will be saved on the server)

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **file** the file path as a String
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **xml\_data** the xml data to write
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **encoding** the specified encoding

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) true if the XML data was successfully written to the specified file path; false otherwise.

**Sample**

```js
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
```

***
