# fileGetContents (Shared)

> Reads a whole file at once, without opening it.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Files
- **URL**: https://wiki.mymp.gg/en/fileGetContents

## Syntax

```lua
string|false fileGetContents(string path)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `path` | `string` | A path inside the calling resource, or `@resource/path` for another resource's file. |

## Returns

The contents, or `false` if the file does not exist, is a folder or could not be read.

A path may not contain `..`, `\` or `:`, nor start with `/`. Another resource's files can only be read; an invalid path logs a warning and the function returns `false`.

## Example

```lua
local text = fileGetContents("config.json")
local config = text and fromJSON(text) or {}
```

## See also

- [fileOpen (Shared)](https://wiki.mymp.gg/en/fileOpen.md): Opens a file that already exists, with the position at its start.
- [fileRead (Shared)](https://wiki.mymp.gg/en/fileRead.md): Reads bytes from a file at the current position and moves the position on.
- [fromJSON (Shared)](https://wiki.mymp.gg/en/fromJSON.md): Turns JSON text into a Lua value. It is the same function as json.decode.
