Fileman
Manage Files
Upload files
This function uploads one or more files to a directory.
Important:
- You must send the files as parts of a multipart/form-data request body. Query parameters cannot carry a file. For security reasons, the system discards any query parameter whose name begins with file-.
- You can't pass the file parts on the command line, and LiveAPI can't call this function at all, because neither can send a multipart/form-data body.
- When you disable the File Storage role, the system disables this function.
- You cannot call this function through WHM API 1's uapi_cpanel function.
Note:
- The system names each stored file after that part's filename attribute, not after the form field's name. By convention, name the fields file-0, file-1, and so on, as the cPanel interface does.
- The system scans every uploaded file for viruses and rejects an infected file.
- The system rejects a filename of . or .., or a filename that contains control characters or any of the <, >, ;, and / characters.
- If one request contains two files with the same name, the system renames the second file. For example, example-2.png.
- For more information about how to use this function in your custom code, read our Use UAPI's Fileman::upload_files Function in Custom Code tutorial.
post/Fileman/upload_files
Query parameters
dirstring path
Example:/home/username/public_html
The directory in which to store the uploaded files.
Note:
- A relative path resolves against the account's home directory.
- This parameter defaults to the account's home directory.
- The system creates the directory if it does not exist.
get_disk_info0 | 1
Example:1
Whether to include the account's disk usage in the response.
- 1 - Return the diskinfo object.
- 0 - Do not return the diskinfo object.
overwrite0 | 1
Example:1
Whether to replace a file that already exists in the target directory.
- 1 - Overwrite the existing file.
- 0 - Fail that file with an "already exists" reason.
permissionsstring unix-file-permission
Example:0600
The permissions to apply to every file in the request, in octal notation.
Note:
- The system reads both 0644 and 644 as octal.
- This parameter defaults to 0644.
- If the system cannot apply the permissions, the upload still succeeds and the function returns a warning for that file.
Response
HTTP Request was successful.
Example response
{
"apiversion": 3,
"func": "upload_files",
"module": "Fileman",
"result": {
"data": {
"diskinfo": {
"file_upload_max_bytes": "104857600.00",
"file_upload_must_leave_bytes": "5242880.00",
"file_upload_remain": "4718592.00",
"spacelimit": "4718592.00",
"spaceremain": "2359296.00",
"spaceused": "2359296.00"
},
"succeeded": 1,
"uploads": [
{
"file": "example.png",
"reason": "Upload of “example.png” succeeded.",
"size": 268,
"status": 1
}
]
},
"status": 1
}
}