Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Files | |
file | conversion.php |
Classes for converting files between different file formats. | |
file | conversion_cleanup_task.php |
A scheduled task to clear up old conversion records. | |
file | converter.php |
Class for converting files between different file formats using unoconv. | |
file | converter_interface.php |
Class for converting files between different file formats. | |
file | externallib.php |
External files API. | |
file | file_archive.php |
Abstraction of general file archives. | |
file | file_browser.php |
Utility class for browsing of files. | |
file | file_exceptions.php |
File handling related exceptions. | |
file | file_info.php |
Base for all file browsing classes. | |
file | file_info_context_course.php |
Utility class for browsing of course files. | |
file | file_info_context_coursecat.php |
Utility class for browsing of curse category files. | |
file | file_info_context_module.php |
Utility class for browsing of module files. | |
file | file_info_context_system.php |
Utility class for browsing of system files. | |
file | file_info_context_user.php |
Utility class for browsing of user files. | |
file | file_info_stored.php |
Utility class for browsing of stored files. | |
file | file_packer.php |
Abstraction of general file packer. | |
file | file_progress.php |
Simple interface for receiving progress during long-running file operations. | |
file | file_storage.php |
Core file storage class definition. | |
file | file_system.php |
Core file system class definition. | |
file | file_system_filedir.php |
Core file system class definition. | |
file | filelib.php |
Functions for file handling. | |
file | mbz_packer.php |
Implementation of .mbz packer. | |
file | stored_file.php |
Definition of a class stored_file. | |
file | stored_file_exporter.php |
Class for exporting stored_file data. | |
file | tgz_extractor.php |
Implementation of .tar.gz extractor. | |
file | tgz_packer.php |
Implementation of .tar.gz packer. | |
file | virtual_root_file.php |
Class simulating empty directories. | |
file | xsendfilelib.php |
X-Sendfile support. | |
file | zip_archive.php |
Implementation of zip file archive. | |
file | zip_packer.php |
Implementation of zip packer. | |
Namespaces | |
namespace | core_files |
| |
namespace | core_files\external |
| |
namespace | core_files\privacy |
| |
namespace | core_files\task |
| |
Classes | |
class | core_files\conversion |
Class representing a conversion currently in progress. More... | |
class | core_files\converter |
Class for converting files between different formats using unoconv. More... | |
interface | core_files\converter_interface |
Class for converting files between different file formats. More... | |
class | core_files\external\stored_file_exporter |
Class for exporting stored_file data. More... | |
class | core_files\privacy\provider |
Data provider class. More... | |
class | core_files\task\conversion_cleanup_task |
A scheduled task to clear up old conversion records. More... | |
class | core_files_external |
class | core_form\privacy\provider |
Implements the privacy API for the core_form subsystem. More... | |
class | curl |
class | curl_cache |
This class is used by cURL class, use case: More... | |
class | file_access_exception |
class | file_archive |
Each file archive type must extend this class. More... | |
class | file_browser |
class | file_exception |
class | file_info |
Base class for things in the tree navigated by file_browser. More... | |
class | file_info_area_backup_section |
Implementation of course section backup area. More... | |
class | file_info_area_course_legacy |
Subclass of file_info_stored for files in the course files area. More... | |
class | file_info_area_course_section |
Represents a course category context in the tree navigated by file_browser. More... | |
class | file_info_context_course |
Represents a course context in the tree navigated by file_browser. More... | |
class | file_info_context_coursecat |
Represents a course category context in the tree navigated by file_browser. More... | |
class | file_info_context_module |
Represents a module context in the tree navigated by file_browser. More... | |
class | file_info_context_system |
Represents the system context in the tree navigated by file_browser. More... | |
class | file_info_context_user |
Represents a user context in the tree navigated by file_browser. More... | |
class | file_info_stored |
Represents an actual file or folder - a row in the file table in the tree navigated by file_browser. More... | |
class | file_packer |
Abstract class for archiving of files. More... | |
class | file_pool_content_exception |
interface | file_progress |
class | file_reference_exception |
class | file_storage |
class | file_system |
class | file_system_filedir |
class | mbz_packer |
class | stored_file |
class | stored_file_creation_exception |
class | tgz_extractor |
Extracts .tar.gz files (POSIX format). More... | |
interface | tgz_extractor_handler |
Interface for callback from tgz_extractor::extract. More... | |
class | tgz_packer |
class | tgz_packer_extract_to_pathname |
Handles extraction to pathname. More... | |
class | tgz_packer_extract_to_storage |
Handles extraction to file storage. More... | |
class | virtual_root_file |
Represents the root directory of an empty file area in the tree navigated by file_browser. More... | |
class | zip_archive |
class | zip_packer |
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... | |
xsendfile ($filepath) | |
Serve file using X-Sendfile header, this needs special server module or configuration. More... | |
byteserving_send_file | ( | $handle, | |
$mimetype, | |||
$ranges, | |||
$filesize | |||
) |
Send requested byterange of file.
resource | $handle | A file handle |
string | $mimetype | The mimetype for the output |
array | $ranges | An array of ranges to send |
string | $filesize | The size of the content if only one range is used |
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.
context | $context | |
string | $component | |
string | $filearea | |
string | $itemid |
bool |
file_copy_file_to_file_area | ( | $file, | |
$filename, | |||
$itemid | |||
) |
Copies a file from one file area to another.
array | $file | Information about the file to be copied. |
string | $filename | The filename. |
int | $itemid | The new file area. |
file_correct_filepath | ( | $str | ) |
Convert any string to a valid filepath.
string | $str |
string | path |
stdClass file_encode_url | ( | $urlbase, | |
$path, | |||
$forcedownload = false , |
|||
$https = false |
|||
) |
Encodes file serving url.
string | $urlbase | |
string | $path | /filearea/itemid/dir/dir/file.exe |
bool | $forcedownload | |
bool | $https | https url required |
string | encoded file url |
file_extension_in_typegroup | ( | $filename, | |
$groups, | |||
$checktype = false |
|||
) |
Checks if file with name $filename has one of the extensions in groups $groups.
string | $filename | name of the file to check |
string | array | $groups | one group or array of groups to check |
bool | $checktype | if true and extension check fails, find the mimetype and check if file mimetype is in mimetypes in groups $groups |
bool |
file_file_icon | ( | $file, | |
$size = null |
|||
) |
Return the relative icon path for a given file.
Usage: // $file - instance of stored_file or file_info $icon = $OUTPUT->image_url(file_file_icon($file))->out(); echo html_writer::empty_tag('img', array('src' => $icon, 'alt' => get_mimetype_description($file)));
or echo $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file));
stored_file | file_info | stdClass | array | $file | (in case of object attributes $file->filename and $file->mimetype are expected) |
int | $size | The size of the icon. Defaults to 16 can also be 24, 32, 64, 128, 256 |
string |
file_folder_icon | ( | $iconsize = null | ) |
Return the relative icon path for a folder image.
Usage: $icon = $OUTPUT->image_url(file_folder_icon())->out(); echo html_writer::empty_tag('img', array('src' => $icon));
or echo $OUTPUT->pix_icon(file_folder_icon(32), '');
int | $iconsize | The size of the icon. Defaults to 16 can also be 24, 32, 48, 64, 72, 80, 96, 128, 256 |
string |
file_get_all_files_in_draftarea | ( | int | $draftitemid, |
string | $filepath = '/' |
||
) |
Returns all of the files in the draftarea.
int | $draftitemid | The draft item ID |
string | $filepath | path for the uploaded files. |
array | An array of files associated with this draft item id. |
file_get_drafarea_files | ( | $draftitemid, | |
$filepath = '/' |
|||
) |
Listing all files (including folders) in current path (draft area) used by file manager.
int | $draftitemid | |
string | $filepath |
stdClass |
file_get_drafarea_folders | ( | $draftitemid, | |
$filepath, | |||
& | $data | ||
) |
stdClass file_get_draft_area_info | ( | $draftitemid, | |
$filepath = '/' |
|||
) |
Returns information about files in a draft area.
$CFG @global stdClass $USER
int | $draftitemid | the draft area item id. |
string | $filepath | path to the directory from which the information have to be retrieved. |
array | with the following entries: 'filecount' => number of files in the draft area. 'filesize' => total size of the files in the draft area. 'foldercount' => number of folders in the draft area. 'filesize_without_references' => total size of the area excluding file references. (more information will be added as needed). |
file_get_file_area_info | ( | $contextid, | |
$component, | |||
$filearea, | |||
$itemid = 0 , |
|||
$filepath = '/' |
|||
) |
Returns information about files in an area.
int | $contextid | context id |
string | $component | component |
string | $filearea | file area name |
int | $itemid | item id or all files if not specified |
string | $filepath | path to the directory from which the information have to be retrieved. |
array | with the following entries: 'filecount' => number of files in the area. 'filesize' => total size of the files in the area. 'foldercount' => number of folders in the area. 'filesize_without_references' => total size of the area excluding file references. |
file_get_typegroup | ( | $element, | |
$groups | |||
) |
Returns array of elements of type $element in type group(s)
string | $element | name of the element we are interested in, usually 'type' or 'extension' |
string | array | $groups | one group or array of groups/extensions/mimetypes |
array |
file_get_upload_error | ( | $errorcode | ) |
Returns description of upload error.
int | $errorcode | found in $_FILES['filename.ext']['error'] |
string | error description string, '' if ok |
moodle_database file_get_user_used_space | ( | ) |
Get used space of files $DB @global stdClass $USER.
int | total bytes |
file_is_draft_area_limit_reached | ( | $draftitemid, | |
$areamaxbytes, | |||
$newfilesize = 0 , |
|||
$includereferences = false |
|||
) |
Returns whether a draft area has exceeded/will exceed its size limit.
Please note that the unlimited value for $areamaxbytes is -1 FILE_AREA_MAX_BYTES_UNLIMITED, not 0.
int | $draftitemid | the draft area item id. |
int | $areamaxbytes | the maximum size allowed in this draft area. |
int | $newfilesize | the size that would be added to the current area. |
bool | $includereferences | true to include the size of the references in the area size. |
bool | true if the area will/has exceeded its limit. |
file_is_draft_areas_limit_reached | ( | int | $userid | ) |
Returns whether a user has reached their draft area upload rate.
int | $userid | The user id |
bool |
file_is_executable | ( | $filename | ) |
Tells whether the filename is executable.
@externalurl http://php.net/manual/en/function.is-executable.php @externalurl https://bugs.php.net/bug.php?id=41062
string | $filename | Path to the file. |
bool | True if the filename exists and is executable; otherwise, false. |
file_merge_draft_area_into_draft_area | ( | $getfromdraftid, | |
$mergeintodraftid | |||
) |
Merge files from two draftarea areas.
This does not handle conflict resolution, files in the destination area which appear to be more recent will be kept disregarding the intended ones.
int | $getfromdraftid | the id of the draft area where are the files to merge. |
int | $mergeintodraftid | the id of the draft area where new files will be merged. |
coding_exception |
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.
Most of the time you do not want to use this. It is intended to be used by asynchronous services which cannot direcly manipulate a final area through a draft area. Instead they add files to a new draft area and merge that new draft into the final area when ready.
int | $draftitemid | the id of the draft area to use. |
int | $contextid | this parameter and the next two identify the file area to save to. |
string | $component | component name |
string | $filearea | indentifies the file area |
int | $itemid | identifies the item id or false for all items in the file area |
array | $options | area options (subdirs=false, maxfiles=-1, maxbytes=0, areamaxbytes=FILE_AREA_MAX_BYTES_UNLIMITED) |
file_mimetype_in_typegroup | ( | $mimetype, | |
$groups | |||
) |
Checks if mimetype $mimetype belongs to one of the groups $groups.
string | $mimetype | |
string | array | $groups | one group or array of groups to check |
bool |
file_overwrite_existing_draftfile | ( | stored_file | $newfile, |
stored_file | $existingfile | ||
) |
Overwrite an existing file in a draft area.
stored_file | $newfile | the new file with the new content and meta-data |
stored_file | $existingfile | the file that will be overwritten |
moodle_exception |
file_pluginfile | ( | $relativepath, | |
$forcedownload, | |||
$preview = null , |
|||
$offline = false , |
|||
$embed = false |
|||
) |
This function delegates file serving to individual plugins.
string | $relativepath | |
bool | $forcedownload | |
null | string | $preview | the preview mode, defaults to serving the original file |
boolean | $offline | If offline is requested - don't serve a redirect to an external file, return a file suitable for viewing offline (e.g. mobile app). |
bool | $embed | Whether this file will be served embed into an iframe. |
file_remove_editor_orphaned_files | ( | $editor | ) |
Removes those files from the user drafts filearea which are not referenced in the editor text.
stdClass | $editor | The online text editor element from the submitted form data. |
file_replace_file_area_in_text | ( | $file, | |
$newid, | |||
$text, | |||
$forcehttps = false |
|||
) |
Rewrites a file area in arbitrary text.
array | $file | General information about the file. |
int | $newid | The new file area itemid. |
string | $text | The text to rewrite. |
bool | $forcehttps | force https urls. |
string | The rewritten text. |
moodle_database file_reset_sortorder | ( | $contextid, | |
$component, | |||
$filearea, | |||
$itemid = false |
|||
) |
reset file sort order number to 0 $DB
int | $contextid | the context id |
string | $component | |
string | $filearea | file area. |
int | bool | $itemid | itemid. |
bool |
file_restore_source_field_from_draft_file | ( | $storedfile | ) |
Restore the original source field from draft files.
Do not use this function because it makes field files.source inconsistent for draft area files. This function will be deprecated in 2.6
stored_file | $storedfile | This only works with draft files |
stored_file |
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.
Passing a new option reverse = true in the $options var will make the function to convert actual URLs in $text to encoded URLs in the @PLUGINFILE@ form.
string | $text | The content that may contain ULRs in need of rewriting. |
string | $file | The script that should be used to serve these files. pluginfile.php, draftfile.php, etc. |
int | $contextid | This parameter and the next two identify the file area to use. |
string | $component | |
string | $filearea | helps identify the file area. |
int | $itemid | helps identify the file area. |
array | $options | bool $options.forcehttps Force the user of https bool $options.reverse Reverse the behaviour of the function mixed $options.includetoken Use a token for authentication. True for current user, int value for other user id. string The processed text. |
file_safe_save_content | ( | $content, | |
$destination | |||
) |
Safely save content to a certain path.
This function tries hard to be atomic by first copying the content to a separate file, and then moving the file across. It also prevents the user to abort a request to prevent half-safed files.
This function is intended to be used when saving some content to cache like $CFG->localcachedir. If you're not caching a file you should use the File API.
string | $content | The file content. |
string | $destination | The absolute path of the final file. |
void |
moodle_database file_set_sortorder | ( | $contextid, | |
$component, | |||
$filearea, | |||
$itemid, | |||
$filepath, | |||
$filename, | |||
$sortorder | |||
) |
Set file sort order.
$DB
int | $contextid | the context id |
string | $component | file component |
string | $filearea | file area. |
int | $itemid | itemid. |
string | $filepath | file path. |
string | $filename | file name. |
int | $sortorder | the sort order of file. |
bool |
format_array_postdata_for_curlcall | ( | $arraydata, | |
$currentdata, | |||
& | $data | ||
) |
Recursive function formating an array in POST parameter.
array | $arraydata | - the array that we are going to format and add into &$data array |
string | $currentdata | - a row of the final postdata array at instant T when finish, it's assign to $data under this format: name[keyname][][]...[]='value' |
array | $data | - the final data array containing all POST parameters : 1 row = 1 parameter |
format_postdata_for_curlcall | ( | $postdata | ) |
Transform a PHP array into POST parameter (see the recursive function format_array_postdata_for_curlcall)
array | $postdata |
array | containing all POST parameters (1 row = 1 POST parameter) |
fulldelete | ( | $location | ) |
Recursively delete the file or folder with path $location.
That is, if it is a file delete it. If it is a folder, delete all its content then delete it. If $location does not exist to start, that is not considered an error.
string | $location | the path to remove. |
bool |
get_mimetype_description | ( | $obj, | |
$capitalise = false |
|||
) |
Obtains descriptions for file types (e.g.
'Microsoft Word document') from the mimetypes.php language file.
mixed | $obj | - instance of stored_file or file_info or array/stdClass with field 'filename' and 'mimetype', or just a string with mimetype (though it is recommended to have filename); In case of array/stdClass the field 'mimetype' is optional. |
bool | $capitalise | If true, capitalises first character of result |
string | Text description |
get_mimetype_for_sending | ( | $filename = '' | ) |
Determine a file's MIME type based on the given filename using the function mimeinfo.
This function retrieves a file's MIME type for a file that will be sent to the user. This should only be used for file-sending purposes just like in send_stored_file, send_file, and send_temp_file. Should the file's MIME type cannot be determined by mimeinfo, it will return 'application/octet-stream' as a default MIME type which should tell the browser "I don't know what type of file this is, so just download it.".
string | $filename | The file's filename. |
string | The file's MIME type or 'application/octet-stream' if it cannot be determined. |
readfile_accel | ( | $file, | |
$mimetype, | |||
$accelerate | |||
) |
Enhanced readfile() with optional acceleration.
string | stored_file | $file | |
string | $mimetype | |
bool | $accelerate |
void |
readfile_allow_large | ( | $path, | |
$filesize = -1 |
|||
) |
The readfile function can fail when files are larger than 2GB (even on 64-bit platforms).
This wrapper uses readfile for small files and custom code for large ones.
string | $path | Path to file |
int | $filesize | Size of file (if left out, will get it automatically) |
int|bool | Size read (will always be $filesize) or false if failed |
readstring_accel | ( | $string, | |
$mimetype, | |||
$accelerate = false |
|||
) |
Similar to readfile_accel() but designed for strings.
string | $string | |
string | $mimetype | |
bool | $accelerate | Ignored |
void |
send_content_uncached | ( | $content, | |
$filename | |||
) |
Serve content which is not meant to be cached.
This is only intended to be used for volatile public files, for instance when development is enabled, or when caching is not required on a public resource.
string | $content | Raw content. |
string | $filename | The file name. |
void |
stdClass send_file_not_found | ( | ) |
Requested file is not found or not accessible, does not return, terminates script.
$CFG @global stdClass $COURSE
send_temp_file | ( | $path, | |
$filename, | |||
$pathisstring = false |
|||
) |
Handles the sending of temporary file to user, download is forced.
File is deleted after abort or successful sending, does not return, script terminated
string | $path | path to file, preferably from moodledata/temp/something; or content of file itself |
string | $filename | proposed file name when saving file |
bool | $pathisstring | If the path is string |
send_temp_file_finished | ( | $path | ) |
Internal callback function used by send_temp_file()
string | $path |
xsendfile | ( | $filepath | ) |
Serve file using X-Sendfile header, this needs special server module or configuration.
Please make sure that all headers are already sent and the all access control checks passed.
string | $filepath |
bool | success |