# LOAD\_FILE

## Syntax

```sql
LOAD_FILE(file_name)
```

## Description

Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and it must be less than the size, in bytes, of the [max\_allowed\_packet](/docs/server/server-management/variables-and-modes/server-system-variables.md#max_allowed_packet) system variable. If the [secure\_file\_priv](/docs/server/server-management/variables-and-modes/server-system-variables.md#secure_file_priv) system variable is set to a non-empty directory name, the file to be loaded must be located in that directory.

If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns `NULL`.

The [character\_set\_filesystem](/docs/server/server-management/variables-and-modes/server-system-variables.md#character_set_filesystem) system variable has controlled interpretation of file names that are given as literal strings.

Statements using the `LOAD_FILE()` function are not [safe for statement based replication](/docs/server/ha-and-performance/standard-replication/unsafe-statements-for-statement-based-replication.md). This is because the slave will execute the `LOAD_FILE()` command itself. If the file doesn't exist on the slave, the function will return `NULL`.

## Examples

```sql
UPDATE t SET blob_col=LOAD_FILE('/tmp/picture') WHERE id=1;
```

## See Also

* [SELECT INTO DUMPFILE](/docs/server/reference/sql-statements/data-manipulation/selecting-data/select-into-dumpfile.md)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/string-functions/load_file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
