Save file

This function saves a file in a directory and encodes it in a character set.

Important:

When you disable the File Storage role, the system disables this function.

SecurityBasicAuth
Request
query Parameters
file
required
string

The files to retrieve.

Example: file=example.html
content
string

The new file's contents. If you do not use this parameter, the function creates a blank file.

Example: content=hi
dir
string <path>

The directory that contains the selected file.

Note:

This parameter defaults to the currently-authenticated user's /home directory.

Example: dir=/home/username/public_html
fallback
integer
Default: 1

Whether the function will return an error or save in the default character set if it cannot save in the specified character set.

  • 1 — Save in the default character set.
  • 0 — Return an error.
Enum: 0 1
Example: fallback=0
from_charset
string
Default: "UTF-8"

The character set encoding of the content parameter's value.

Example: from_charset=UTF-8
to_charset
string
Default: "UTF-8"

The character set encoding in which to encode the file.

Example: to_charset=ASCII
Responses
200

HTTP Request was successful.

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object
get/Fileman/save_file_content
Request samples
uapi --output=jsonpretty \
  --user=username \
  Fileman \
  save_file_content \
  file='example.html'
Response samples
application/json
{
  • "apiversion": 3,
  • "func": "save_file_content",
  • "module": "Fileman",
  • "result": {
    • "data": {
      • "from_charset": "UTF-8",
      • "path": "/home/user/public_html/example.html",
      • "to_charset": "ASCII"
      },
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}