Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation



integrationblogcta.jpg

Fileman Module Documentation

The Fileman module provides access to file functions such as listing directories and viewing files.

The functions within this module may or may not be governed by a feature list. The required feature list may vary from function to function, to review a total list of the available features sets on a cPanel server, please see "Feature Manager" in WHM.

Fileman::listfiles

API Version: 2 - Click here for documentation
Description: List files and attributes contained within a specified directory.
Parameters:  
  checkleaf (boolean (optional))
  A value of '1' will cause the function to add the 'isleaf' parameter to the output key. '1' if you would like to add it to the output key. (e.g. 'checkleaf' => '1' indicates a directory that has no subdirectories.).
  dir (string (optional))
  The directory that contains the files you wish to browse. '/' represents your home directory. If this parameter is not specified, the home directory will be used.
  filelist (boolean (optional))
  A value of '1' tells the function to look for keys that begin with 'filepath-*'. These keys are used to indicate specific files to list.
  filepath-* (string (optional))
  This parameter allows you to specify files you want listed with the output if 'filelist' is set to '1'. This can be any number of parameters, such as 'filelist-A', 'filelist-B', etc. Each of these keys indicate a file you wish to view.
  needmime (boolean (optional))
  A value of '1' indicates that you would like the function to add the 'mimename' and 'mimetype' output keys.
  showdotfiles (boolean (optional))
  A value of '1' indicates that you would like the function to add dotfiles to the output keys.
  types (strings (separated by pipes) (optional))
  This parameter acts as a filter, allowing you to specify which file types you wish to view. Acceptable values include 'dir', 'file', and 'special'. To add multiple values, separate each type using a pipe (|). For example, 'dir | file' would only show directories and files.
Returns:  
 
<data>
  <ctime> An integer value that contains the file's creation time in Unix time.</ctime>
  <uid> An integer value that contains the user ID (uid) of the user who owns the file.</uid>
  <mtime> An integer value that contains the last time the file was modified in Unix time.</mtime>
  <mode> A string value that contains the octal mode of the file, including the file type.</mode>
  <isleaf> A boolean value that indicates whether or not a directory contains any subdirectories. '1' if the directory does not contain subdirectories.</isleaf>
  <mimename> A string value that contains the file's mime name.</mimename>
  <file> A string value that contains the file's name.</file>
  <path> A string value that contains the full path to the file, not including the filename.</path>
  <nicemode> An integer value that contains the octal permissions with the file type masked out. (e.g. 0700)</nicemode>
  <size> An integer value that contains the size of the file in bytes.</size>
  <humansize> A string value that contains the file size in human terms. (e.g. 4 G)</humansize>
  <fullpath> A string value that contains the full path to the file, including the filename.</fullpath>
  <type> A string value that contains the file type. (e.g. 'file' or 'dir')</type>
  <mimetype> A string value that contains the mime type.</mimetype>
  <gid> An integer value that contains the group ID (gid) of group that owns the file.</gid>
</data>

Fileman::viewfile

API Version: 2 - Click here for documentation
Description: View a file within your home directory. This function will also display additional information about the file, such as the contents of a tarball, a link to an image, and more.
Parameters:  
  dir (string (optional))
  The directory in which the file is located. This path must be relative to the user's home directory. (e.g. 'public_html/myfiles/').
  file (string)
  The path to the file you wish to view.
Returns:  
 
<data>
  <contents> A string value containing the contents of the file. If the file is a text file, this value will contain the contents of the text file. If the file is an archive, this value will contain a list of the contents within the archive. If the file is an image, this value will contain an img HTML tag pointing to the file.</contents>
  <dir> A string value that contains the directory in which the file is located.</dir>
  <file> A string value that contains the name of the file.</file>
  <fileinfo> A string value that contains the file type of the file as determined by the 'file' command.</fileinfo>
  <filetype> A string value that contains either 'file' or 'dir' depending on whether the entry is a file or directory.</filetype>
  <mimename> A string value that contains the name of the mime type used with this file without slashes.</mimename>
  <mimetype> A string value that contains the mime type of the file.</mimetype>
</data>

Fileman::statfiles

API Version: 2 - Click here for documentation
Description: Retrieve information about specific files.
Parameters:  
  dir (string (optional))
  The directory whose files you wish to review. (e.g. /home/user/public_html/files) If you do not specify a value for this parameter, it will default to your home directory.
  files (string)
  The name of the file whose statistics you wish to review. You may define multiple files by separating each value with a pipe (|). (e.g. 'file1|file2|file3').
Returns:  
 
<data>
  <path> A string value that contains the path to the file.</path>
  <mimeinfo> A string value that contains the mime type of the file.</mimeinfo>
  <nicemode> A string value that contains the octal permissions of the file. (e.g. '0755' or '0700')</nicemode>
  <group> A string value that contains the group that owns the file.</group>
  <gid> A string value that contains the numerical group ID (GID) of the file.</gid>
  <humansize> A string value that contains the size of the file in a human readable format.</humansize>
  <user> A string value that contains the user who owns the file.</user>
  <ctime> A string value that contains the time the file was created.</ctime>
  <mode> A string value that contains the mode of the file.</mode>
  <mtime> A string value that contains the last time the file was modified.</mtime>
  <file> A string value that contains the file's name.</file>
  <size> A string value that contains the size of the file in bytes.</size>
  <type> A string value that contains the file type. (e.g. file)</type>
  <uid> A string value that contains the file's user ID (UID).</uid>
</data>

Fileman::getdir

API Version: 2 - Click here for documentation
Description: Retrieve the home directory path for a given account in URI format.
Parameters:  
  dir (string (optional))
  The directory you wish to retrieve in URI format.
Returns:  
 
<data>
  <dir> A string value that contains the path to the home directory. Remember: This value is in URI format. (e.g. '%2fhome%2fuser' if the directory were '/home/user')</dir>
</data>

Fileman::getedittype

API Version: 2 - Click here for documentation
Description: Attempt to guess the filetype of a specific file. This module uses the 'file' command and searches through file extensions. You must have access to the 'filemanager' feature to use this function.
Parameters:  
  dir (string)
  The directory that contains the file you wish to query.
  editor (string (optional))
  By setting this parameter to 'editarea', certain filetypes will return a long-style name. (e.g. 'javascript' instead of 'js').
  file (string)
  The name of the file you wish to query.
Returns:  
 
<data>
  <type> A string value that contains the filetype. (e.g. 'perl' or 'js')</type>
</data>

Fileman::getpath

API Version: 2 - Click here for documentation
Description: Split a specific directory into individual parts.
Parameters:  
  dir (string)
  The URI-encoded path you wish to split into individual parts. (e.g. %2fhome%2fuser%2fpublic_html%2fdirectory9%2fsubdirectory1).
Returns:  
 
<data>
  <dir> A string value that contains the full directory path. (e.g. /home/user/public_html/directory9/subdirectory1)</dir>
  <dirparts>
    <dirurl> A string value that contains the full path to a subdirectory of the your home directory. (e.g. '/public_html/')</dirurl>
    <dirpart> A string value that contains a single subdirectory of the home directory. (e.g. '/public_html/')</dirpart>
  </dirparts>
  <dirurl> A string value that contains the full path to a subdirectory of another subdirectory. (e.g. '/public_html/webapp/')</dirurl>
  <dirpart> A string value that contains a single subdirectory of a subdirectory. (e.g. '/webapp/')</dirpart>
</data>

Fileman::getdiractions

API Version: 2 - Click here for documentation
Description: Retrieve a list of actions you are able to perform on a file or directory. These values will include a URL fragment that you can append to a cPanel File Manager URL.
Parameters:  
  dir (string)
  The relative directory that contains the files you wish to query. '/' is your home directory.
  file (string)
  The file or directory for which you wish to query.
Returns:  
 
<data>
  <actions>
    <actionname> 'Delete this folder and all files under it'</actionname>
    <target> 'file'</target>
    <actionurl> A string value that contains the URL fragment for File Manager. (e.g. trashit.html?dir=%2fhome%2fusername&file=public_html')</actionurl>
    <action> 'delete'</action>
  </actions>
  <actionname> 'Change Permissions'</actionname>
  <target> 'file'</target>
  <actionurl> 'perm.html?dir=%2fhome%2fusername&file=public_html'</actionurl>
  <action> 'chmod'</action>
  <actionname> 'Rename Folder'</actionname>
  <target> 'file'</target>
  <actionurl> 'rename.html?dir=%2fhome%2fusername&file=public_html'</actionurl>
  <action> 'rename'</action>
  <actionname> 'Copy this folder'</actionname>
  <target> 'dir'</target>
  <actionurl> 'fileop.html?fileop=copy&opdir=%2fhome%2fusername&opfile=public_html'</actionurl>
  <action> 'copy'</action>
  <actionname> 'Move this folder'</actionname>
  <target> 'dir'</target>
  <actionurl> 'fileop.html?fileop=move&opdir=%2fhome%2fusername&opfile=public_html'</actionurl>
  <action> 'move'</action>
  <mimename> A string value that contains the mime name of the selected file.</mimename>
  <file> A string value that contains the value in 'file'.</file>
  <mimetype> A string value contains the mime type of the selected file.</mimetype>
  <dir> A string value that contains the full path to the directory specified in the 'dir' parameter.</dir>
</data>

Fileman::getabsdir

API Version: 2 - Click here for documentation
Description: List cPanel's current working directory. By default, this will be /usr/local/cpanel/base.
Parameters:  
  dir (string (optional))
  The path you wish to be returned by this function. If you pass this parameter a relative value, it will be appended to /usr/local/cpanel/base. If you pass this parameter an absolute value, the function will return this value.
Returns:  
 
<data>
  <absdir> A string value that contains the full path to cPanel current working directory.</absdir>
</data>

Fileman::getdiskinfo

API Version: 2 - Click here for documentation
Description: Retrieve disk usage statistics about your account. These values will include your quota and the amount of disk space used by your cPanel account.
Returns:  
 
<data>
  <file_upload_max_bytes> The maximum file size, in bytes, you can upload via cPanel's File Manager.</file_upload_max_bytes>
  <file_upload_must_leave_bytes> The amount of disk space, in bytes, that must be reserved to avoid quota issues due to file uploads.</file_upload_must_leave_bytes>
  <file_upload_max_bytes_humansize> A string value that contains the amount of disk space, in a human recognizable format, that must be reserved to avoid issues due to file uploads. (e.g. 50 MB)</file_upload_max_bytes_humansize>
  <file_upload_must_leave_bytes_humansize> The maximum file size you can upload via cPanel's File Manager, in a human readable format.</file_upload_must_leave_bytes_humansize>
  <file_upload_remain_humansize> A string value that contains the remaining quota in a human readable format.</file_upload_remain_humansize>
  <spaceused> The amount of disk space used in bytes.</spaceused>
  <spacelimit> Your account's quota in bytes.</spacelimit>
  <file_upload_remain> Your account's remaining file upload space in bytes.</file_upload_remain>
  <spacelimit_humansize> A string value that contains your account's quota in a human readable format.</spacelimit_humansize>
  <spaceremain_humansize> A string value that contains your account's remaining disk space in a human readable format.</spaceremain_humansize>
  <spaceremain> A floating point variable that contains your account's remaining disk space in bytes.</spaceremain>
  <spaceused_humansize> A string value that contains your account's remaining disk space in a human readable format.</spaceused_humansize>
</data>

Fileman::search

API Version: 2 - Click here for documentation
Description: Perform a recursive search for filenames within a specific directory. You must have access to the 'filemanager' feature to use this function.
Parameters:  
  dir (string (optional))
  The top-level directory in which you wish to begin your search. Remember: Subdirectories of this directory will also be searched. If you do not specify this parameter, it will default to your home directory.
  attributes (string (optional))
  A list of various attributes you wish to return for each result, separated by a pipe (|) character. Valid values include: user, groupusage (actual disk usage), size, type (file, dir, char, block, fifo, link, socket), mode (permissions only), ctime, atime, mtime. (e.g. attributes=user|groupusage|size|type|mode|ctime|atime|mtime).
  recursive (boolean (optional))
  Perform the search recursively. This value defaults to 1.
  mimeinfo (boolean (optional))
  Specifies whether or not you wish to return MIME information for each result. This value defaults to 1.
  regex (Regular Expression (optional))
  A regular expression (or string) that indicates the file to be searched.
Returns:  
 
<data>
  <mimeinfo> A string value that contains the file's mime type. (e.g. text-html).</mimeinfo>
  <file> A string value that contains the path to file.</file>
  <group> A string value that contains the name of the group that owns the file.</group>
  <user> A string value that contains the name of the user that owns the file.</user>
  <ctime> A string value that contains the time at which the file was created.</ctime>
  <mtime> A string value that contains the last time the file was modified.</mtime>
  <usage> An integer value that contains the actual disk usage. </usage>
  <mode> An integer value, in decimal notation, of the file permissions. (e.g. printf('%d ,-0600).</mode>
  <file> A string value that contains the path to the file.</file>
  <size> An integer value that contains the size of the file in bytes.</size>
  <type> A string value that contains the type of file. (e.g. file, dir, char, block, fifo, link, or socket)</type>
  <atime> A string value that contains the last time the file was accessed.</atime>
</data>

Fileman::autocompletedir

API Version: 2 - Click here for documentation
Description: Search for files and directories that begin with a specified string.
Parameters:  
  dirsonly (boolean (optional))
  When this parameter is passed a value of '1', only directories are returned.
  path (string)
  The full path to the directory you wish to search. (e.g. /home/user/public_html/test/).
Returns:  
 
<data>
  <file> A string value that contains a filename or directory that matches the 'path' value.</file>
</data>

Fileman::getfileactions

API Version: 2 - Click here for documentation
Description: Returns actions that can be performed on a file, including a URL fragment which can be appended to a cPanel File Manager URL.
Parameters:  
  dir (string)
  Base directory for the file or directory you want to query about. Note that it requires the full path.
  file (string)
  File or directory name to query for.
  newedit (boolean (optional))
  Will cause certain output functions to create landing page URL's and targets for 'file' instead of 'editor'.
Returns:  
 
<data>
  <actions>
    <actionname> 'Show File'</actionname>
    <target> 'viewer'</target>
    <actionurl> 'showfile.html?dir=&file=$filename' the 'actionurl' can be appended to 'https://[ip address]:2083/frontend/x3/filemanager/'</actionurl>
    <action> 'show'</action>
  </actions>
  <actionname> 'Delete File'</actionname>
  <target> 'file'</target>
  <actionurl> 'trashit.html?dir=&file=filename.txt'</actionurl>
  <action> 'delete'</action>
  <actionname> 'Edit File with Code Editor'</actionname>
  <target> 'editor'</target>
  <actionurl> 'editit_code.html?dir=&file=filename.txt'</actionurl>
  <action> 'codeedit'</action>
  <actionname> 'Edit File'</actionname>
  <target> 'editor'</target>
  <actionurl> 'editit.html?dir=&file=filename.txt'</actionurl>
  <action> 'edit'</action>
  <actionname> 'Change Permissions'</actionname>
  <target> 'file'</target>
  <actionurl> 'perm.html?dir=&file=filename.txt'</actionurl>
  <action> 'chmod'</action>
  <actionname> 'Rename File'</actionname>
  <target> 'file'</target>
  <actionurl> 'rename.html?dir=&file=filename.txt'</actionurl>
  <action> 'rename'</action>
  <actionname> 'Copy File'</actionname>
  <target> 'dir'</target>
  <actionurl> 'fileop.html?opdir=&opfile=filename.txt&fileop=copy'</actionurl>
  <action> 'copy'</action>
  <actionname> 'Move File'</actionname>
  <target> 'dir'</target>
  <actionurl> 'fileop.html?opdir=&opfile=filename.txt&fileop=move'</actionurl>
  <action> 'move'</action>
  <actionname> 'Download File'</actionname>
  <target> 'file'</target>
  <actionurl> '/download?file=/filename.txt.html'</actionurl>
  <action> 'download'</action>
  <fileinfo> description of file</fileinfo>
  <mimename> mime name</mimename>
  <file> file name from the 'file' parameter </file>
  <mimetype> mime-type of the file</mimetype>
  <dir> directory from the 'dir' field</dir>
</data>

Fileman::fileop

API Version: 2 - Click here for documentation
Description: Perform an operation on a file or group of files. You can use this function to copy, move, rename, chmod, extract and compress, link and unlink, and trash files and directories.
Parameters:  
  op (string)
  The operation to perform. Acceptable values include 'copy', 'move', 'rename', 'chmod', 'extract', 'compress', 'link', 'unlink', and 'trash' (move to .trash directory).
  sourcefiles (comma delimited list)
  The files on which you wish to perform the operation. You can include multiple files by separating each file with a comma (,). Do not add spaces.
  destfiles (comma delimited list)
  A comma separated list of destination filenames. If multiple sourcefiles are listed with multiple destination files ('destfiles'), the function attempts to handle each transaction on a 1-to-1 basis. If only 1 file is specified in 'sourcefiles', it will be moved, or copied, or etc. to the first directory listed.
  doubledecode (boolean)
  Entering '1' to this parameter will cause the function to decode the URI-encoded variables 'srcfiles' and 'destfiles'.
  metadata (string)
  This parameter contains any added values required by the operation. When using 'compress', this would be the archive type. Acceptable values for the 'compress' operation include 'zip', 'tar.gz', 'tar.bz2', 'tar', 'gz', and 'bz2'. The 'chmod' operation requires octal permissions (e.g. '0755' or '0700').
Returns:  
 
<data>
  <dest> A string value that contains the destination filename.</dest>
  <src> A string value that contains the source filename.</src>
  <output> A string value that contains any error message or relevant output, such as compression percentage. This value may or may not be present in the output.</output>
  <result> A boolean value indicating success or failure. '1' if the function completes successfully.</result>
</data>

Fileman::mkdir

API Version: 2 - Click here for documentation
Description: Create a new directory. This function is only available in cPanel and WHM 11.30 and later.
Parameters:  
  path (string)
  The path for the new directory, relative to the user's home directory.
  name (string)
  The name of the new directory.
  permissions (string (optional))
  An octal string that contains the new directory's file permissions. This parameter's default value is 0755.
Returns:  
 
<data>
  <path> A string value that contains the path to the new directory, relative to the user's home directory., </path>
  <name> A string value that contains the name of the new directory.</name>
  <permissions> A string value that contains the octal permissions of the new directory. (e.g. '0755' or '0700')</permissions>
</data>

Fileman::savefile

API Version: 2 - Click here for documentation
Description: Save the contents of a string to a file. This function is only available in cPanel and WHM 11.30 and later.
Parameters:  
  dir (string)
  The path to the new file, relative to the user's home directory.
  filename (string)
  The name of the new file.
  content (string)
  The content you wish to save to the file. Input for this parameter must be given in UTF-8.
  charset (string (optional))
  The character set to which the content will be converted when the file is saved. This parameter's default value is UTF-8. We strongly recommend that you do not use this parameter.
Returns:  
 
<data>

</data>

Topic revision: r2 - 26 Mar 2012 - 15:55:20 - Main.JenniferDoubrava