Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Classes | Functions | Variables
filelib.php File Reference

Functions for file handling. More...

Classes

class  curl
 
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. More...
 
 download_file_content ($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false, $tofile=NULL, $calctimeout=false)
 
 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. More...
 
 file_copy_file_to_file_area ($file, $filename, $itemid)
 Copies a file from one file area to another. More...
 
 file_correct_filepath ($str)
 Convert any string to a valid filepath. More...
 
stdClass file_encode_url ($urlbase, $path, $forcedownload=false, $https=false)
 Encodes file serving url. More...
 
 file_extension_icon ($filename, $size=NULL)
 
 file_extension_in_typegroup ($filename, $groups, $checktype=false)
 Checks if file with name $filename has one of the extensions in groups $groups. More...
 
 file_file_icon ($file, $size=null)
 Return the relative icon path for a given file. More...
 
 file_folder_icon ($iconsize=null)
 Return the relative icon path for a folder image. More...
 
 file_get_all_files_in_draftarea (int $draftitemid, string $filepath='/')
 Returns all of the files in the draftarea. More...
 
 file_get_drafarea_files ($draftitemid, $filepath='/')
 Listing all files (including folders) in current path (draft area) used by file manager. More...
 
 file_get_drafarea_folders ($draftitemid, $filepath, &$data)
 Generate a folder tree of draft area of current USER recursively. More...
 
stdClass file_get_draft_area_info ($draftitemid, $filepath='/')
 Returns information about files in a draft area. More...
 
 file_get_file_area_info ($contextid, $component, $filearea, $itemid=0, $filepath='/')
 Returns information about files in an area. More...
 
 file_get_submitted_draft_itemid ($elname)
 
 file_get_typegroup ($element, $groups)
 Returns array of elements of type $element in type group(s) More...
 
moodle_database file_get_unused_draft_itemid ()
 
 file_get_upload_error ($errorcode)
 Returns description of upload error. More...
 
moodle_database file_get_user_used_space ()
 Get used space of files $DB @global stdClass $USER. More...
 
 file_is_draft_area_limit_reached ($draftitemid, $areamaxbytes, $newfilesize=0, $includereferences=false)
 Returns whether a draft area has exceeded/will exceed its size limit. More...
 
 file_is_draft_areas_limit_reached (int $userid)
 Returns whether a user has reached their draft area upload rate. More...
 
 file_is_executable ($filename)
 Tells whether the filename is executable. More...
 
 file_merge_draft_area_into_draft_area ($getfromdraftid, $mergeintodraftid)
 Merge files from two draftarea areas. More...
 
 file_merge_draft_areas ($draftitemid, $usercontextid, $text, $forcehttps=false)
 
 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. More...
 
 file_mimetype_icon ($mimetype, $size=NULL)
 
 file_mimetype_in_typegroup ($mimetype, $groups)
 Checks if mimetype $mimetype belongs to one of the groups $groups. More...
 
 file_overwrite_existing_draftfile (stored_file $newfile, stored_file $existingfile)
 Overwrite an existing file in a draft area. More...
 
 file_pluginfile ($relativepath, $forcedownload, $preview=null, $offline=false, $embed=false)
 This function delegates file serving to individual plugins. More...
 
 file_postupdate_standard_editor ($data, $field, array $options, $context, $component=null, $filearea=null, $itemid=null)
 
 file_postupdate_standard_filemanager ($data, $field, array $options, $context, $component, $filearea, $itemid)
 
stdClass file_prepare_draft_area (&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null)
 
 file_prepare_standard_editor ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null)
 
 file_prepare_standard_filemanager ($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null)
 
 file_remove_editor_orphaned_files ($editor)
 Removes those files from the user drafts filearea which are not referenced in the editor text. More...
 
 file_replace_file_area_in_text ($file, $newid, $text, $forcehttps=false)
 Rewrites a file area in arbitrary text. More...
 
moodle_database file_reset_sortorder ($contextid, $component, $filearea, $itemid=false)
 reset file sort order number to 0 $DB More...
 
 file_restore_source_field_from_draft_file ($storedfile)
 Restore the original source field from draft files. More...
 
 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. More...
 
 file_rewrite_urls_to_pluginfile ($text, $draftitemid, $forcehttps=false)
 
 file_safe_save_content ($content, $destination)
 Safely save content to a certain path. More...
 
stdClass file_save_draft_area_files ($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false)
 
moodle_database file_set_sortorder ($contextid, $component, $filearea, $itemid, $filepath, $filename, $sortorder)
 Set file sort order. More...
 
 format_array_postdata_for_curlcall ($arraydata, $currentdata, &$data)
 Recursive function formating an array in POST parameter. More...
 
 format_postdata_for_curlcall ($postdata)
 Transform a PHP array into POST parameter (see the recursive function format_array_postdata_for_curlcall) More...
 
 fulldelete ($location)
 Recursively delete the file or folder with path $location. More...
 
 get_mimetype_description ($obj, $capitalise=false)
 Obtains descriptions for file types (e.g. More...
 
 get_mimetype_for_sending ($filename='')
 Determine a file's MIME type based on the given filename using the function mimeinfo. More...
 
get_mimetypes_array ()
 
 mimeinfo ($element, $filename)
 
 mimeinfo_from_type ($element, $mimetype)
 
 readfile_accel ($file, $mimetype, $accelerate)
 Enhanced readfile() with optional acceleration. More...
 
 readfile_allow_large ($path, $filesize=-1)
 The readfile function can fail when files are larger than 2GB (even on 64-bit platforms). More...
 
 readstring_accel ($string, $mimetype, $accelerate=false)
 Similar to readfile_accel() but designed for strings. More...
 
 send_content_uncached ($content, $filename)
 Serve content which is not meant to be cached. More...
 
 send_file ($path, $filename, $lifetime=null, $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='', $dontdie=false, array $options=array())
 
stdClass send_file_not_found ()
 Requested file is not found or not accessible, does not return, terminates script. More...
 
 send_header_404 ()
 Helper function to send correct 404 for server.
 
 send_stored_file ($stored_file, $lifetime=null, $filter=0, $forcedownload=false, array $options=array())
 
 send_temp_file ($path, $filename, $pathisstring=false)
 Handles the sending of temporary file to user, download is forced. More...
 
 send_temp_file_finished ($path)
 Internal callback function used by send_temp_file() More...
 

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.
 

Detailed Description

Functions for file handling.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later