Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
filelib.php File Reference

Classes

class  curl
 RESTful cURL class. More...
 
class  curl_cache
 This class is used by cURL class, use case: More...
 

Functions

 byteserving_send_file ($handle, $mimetype, $ranges, $filesize)
 Send requested byterange of file.
 
 download_file_content ($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false, $tofile=NULL, $calctimeout=false)
 Fetches content of file from Internet (using proxy if defined).
 
 file_area_contains_subdirs (context $context, $component, $filearea, $itemid)
 Detects if area contains subdirs, this is intended for file areas that are attached to content migrated from 1.x where subdirs were allowed everywhere.
 
 file_copy_file_to_file_area ($file, $filename, $itemid)
 Copies a file from one file area to another.
 
 file_correct_filepath ($str)
 Convert any string to a valid filepath.
 
stdClass file_encode_url ($urlbase, $path, $forcedownload=false, $https=false)
 Encodes file serving url.
 
 file_extension_icon ($filename, $unused=null)
 Returns the relative icon path for a given file name.
 
 file_extension_in_typegroup ($filename, $groups, $checktype=false)
 Checks if file with name $filename has one of the extensions in groups $groups.
 
 file_file_icon ($file, $unused=null)
 Return the relative icon path for a given file.
 
 file_folder_icon ($unused=null)
 Return the relative icon path for a folder image.
 
 file_get_all_files_in_draftarea (int $draftitemid, string $filepath='/')
 Returns all of the files in the draftarea.
 
 file_get_drafarea_files ($draftitemid, $filepath='/')
 Listing all files (including folders) in current path (draft area) used by file manager.
 
 file_get_drafarea_folders ($draftitemid, $filepath, &$data)
 Generate a folder tree of draft area of current USER recursively.
 
stdClass file_get_draft_area_info ($draftitemid, $filepath='/')
 Returns information about files in a draft area.
 
 file_get_file_area_info ($contextid, $component, $filearea, $itemid=0, $filepath='/')
 Returns information about files in an area.
 
 file_get_submitted_draft_itemid ($elname)
 Returns draft area itemid for a given element.
 
 file_get_typegroup ($element, $groups)
 Returns array of elements of type $element in type group(s)
 
moodle_database file_get_unused_draft_itemid ()
 Generate a draft itemid.
 
 file_get_upload_error ($errorcode)
 Returns description of upload error.
 
moodle_database file_get_user_used_space ()
 Get used space of files $DB @global stdClass $USER.
 
 file_is_draft_area_limit_reached ($draftitemid, $areamaxbytes, $newfilesize=0, $includereferences=false)
 Returns whether a draft area has exceeded/will exceed its size limit.
 
 file_is_draft_areas_limit_reached (int $userid)
 Returns whether a user has reached their draft area upload rate.
 
 file_is_executable ($filename)
 Tells whether the filename is executable.
 
 file_is_svg_image_from_mimetype (string $mimetype)
 Attempt to determine whether the specified mime-type is an SVG image or not.
 
 file_merge_draft_area_into_draft_area ($getfromdraftid, $mergeintodraftid)
 Merge files from two draftarea areas.
 
 file_merge_draft_areas ($draftitemid, $usercontextid, $text, $forcehttps=false)
 Finds all draft areas used in a textarea and copies the files into the primary textarea.
 
 file_merge_files_from_draft_area_into_filearea ($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null)
 Add files from a draft area into a final area.
 
 file_mimetype_icon ($mimetype, $unused=null)
 Returns the relative icon path for a given mime type.
 
 file_mimetype_in_typegroup ($mimetype, $groups)
 Checks if mimetype $mimetype belongs to one of the groups $groups.
 
 file_overwrite_existing_draftfile (stored_file $newfile, stored_file $existingfile)
 Overwrite an existing file in a draft area.
 
 file_pluginfile ($relativepath, $forcedownload, $preview=null, $offline=false, $embed=false)
 This function delegates file serving to individual plugins.
 
 file_postupdate_standard_editor ($data, $field, array $options, $context, $component=null, $filearea=null, $itemid=null)
 Prepares the content of the 'editor' form element with embedded media files to be saved in database.
 
 file_postupdate_standard_filemanager ($data, $field, array $options, $context, $component, $filearea, $itemid)
 Saves files modified by File manager formslib element.
 
stdClass file_prepare_draft_area (&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null)
 Initialise a draft file area from a real one by copying the files.
 
 file_prepare_standard_editor ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null)
 Prepares 'editor' formslib element from data in database.
 
 file_prepare_standard_filemanager ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null)
 Saves text and files modified by Editor formslib element.
 
 file_remove_editor_orphaned_files ($editor)
 Removes those files from the user drafts filearea which are not referenced in the editor text.
 
 file_replace_file_area_in_text ($file, $newid, $text, $forcehttps=false)
 Rewrites a file area in arbitrary text.
 
moodle_database file_reset_sortorder ($contextid, $component, $filearea, $itemid=false)
 reset file sort order number to 0 $DB
 
 file_restore_source_field_from_draft_file ($storedfile)
 Restore the original source field from draft files.
 
 file_rewrite_pluginfile_urls ($text, $file, $contextid, $component, $filearea, $itemid, array $options=null)
 Convert encoded URLs in $text from the @PLUGINFILE@/... form to an actual URL.
 
 file_rewrite_urls_to_pluginfile ($text, $draftitemid, $forcehttps=false)
 Convert the draft file area URLs in some content to @PLUGINFILE@ tokens ready to be saved in the database.
 
 file_safe_save_content ($content, $destination)
 Safely save content to a certain path.
 
stdClass file_save_draft_area_files ($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false)
 Saves files from a draft file area to a real one (merging the list of files).
 
moodle_database file_set_sortorder ($contextid, $component, $filearea, $itemid, $filepath, $filename, $sortorder)
 Set file sort order.
 
 format_array_postdata_for_curlcall ($arraydata, $currentdata, &$data)
 Recursive function formating an array in POST parameter.
 
 format_postdata_for_curlcall ($postdata)
 Transform a PHP array into POST parameter (see the recursive function format_array_postdata_for_curlcall)
 
 fulldelete ($location)
 Recursively delete the file or folder with path $location.
 
 get_mimetype_description ($obj, $capitalise=false)
 Obtains descriptions for file types (e.g.
 
 get_mimetype_for_sending ($filename='')
 Determine a file's MIME type based on the given filename using the function mimeinfo.
 
get_mimetypes_array ()
 Returns a list of information about file types based on extensions.
 
 get_moodle_proxy_url ()
 Returns the moodle proxy configuration as a formatted url.
 
 mimeinfo ($element, $filename)
 Obtains information about a filetype based on its extension.
 
 mimeinfo_from_type ($element, $mimetype)
 Obtains information about a filetype based on the MIME type rather than the other way around.
 
 readfile_accel ($file, $mimetype, $accelerate)
 Enhanced readfile() with optional acceleration.
 
 readfile_allow_large ($path, $filesize=-1)
 The readfile function can fail when files are larger than 2GB (even on 64-bit platforms).
 
 readstring_accel ($string, $mimetype, $accelerate=false)
 Similar to readfile_accel() but designed for strings.
 
 send_content_uncached ($content, $filename)
 Serve content which is not meant to be cached.
 
 send_file ($path, $filename, $lifetime=null, $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='', $dontdie=false, array $options=array())
 Handles the sending of file data to the user's browser, including support for byteranges etc.
 
stdClass send_file_not_found ()
 Requested file is not found or not accessible, does not return, terminates script.
 
 send_header_404 ()
 Helper function to send correct 404 for server.
 
 send_stored_file ($storedfile, $lifetime=null, $filter=0, $forcedownload=false, array $options=array())
 Handles the sending of file data to the user's browser, including support for byteranges etc.
 
 send_temp_file ($path, $filename, $pathisstring=false)
 Handles the sending of temporary file to user, download is forced.
 
 send_temp_file_finished ($path)
 Internal callback function used by send_temp_file()
 

Variables

const BYTESERVING_BOUNDARY 's1k2o3d4a5k6s7'
 BYTESERVING_BOUNDARY - string unique string constant.
 
const DRAFT_AREA_BUCKET_CAPACITY 50
 Capacity of the draft area bucket when using the leaking bucket technique to limit the draft upload rate.
 
const DRAFT_AREA_BUCKET_LEAK 0.2
 Leaking rate of the draft area bucket when using the leaking bucket technique to limit the draft upload rate.
 
const FILE_AREA_MAX_BYTES_UNLIMITED -1
 Unlimited area size constant.
 
const IGNORE_FILE_MERGE -1
 Do not process file merging when working with draft area files.