You are on page 1of 2

Functions Related to file from filelib.

php
Function Name Description
Modifies the content of the uploaded file by
file_modify_html_header($text) adding html headers and giving some look and
feel to the uploaded file text.

byteserving_send_file($filename,
Send requested byte range of file.
$mimetype, $ranges)

readfile_chunked($filename, Improves memory consumption and works around


$retbytes=true) buggy readfile()

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
fulldelete($location)
content then delete it. If $location does
not exist to start, that is not considered
an error.

put_records_csv($file, $records, $table


Write all the records into CSV file.
= NULL)

Retrieve all the records from the CSV file


get_records_csv($file, $table) and if $table exist than return all the
$row[] to the form.

send_file($path,$filename,$lifetime= Handles the sending of file data to the


'default',$filter=0,$pathisstring=false, user's browser, including support for
$forcedownload=false, $mimetype='') byteranges etc.

Call internally by send_temp_file() function


send_temp_file_finished($path) to remove the instance of the file from temp
folder.

Handles the sending of temporary file to


send_temp_file($path, $filename,
user, download is forced. File is deleted
$pathisstring=false)
after abort or successful sending.

Obtains descriptions for file types (e.g.


'Microsoft Word document') from the
mimetypes.php language file.
get_mimetype_description($mimetype,
$capitalise=false)
Checks for other type which are having no
header description like ‘application/pdf’
format.
Get information about a filetype based on
mimeinfo_from_icon($element, $icon)
the icon file.

Obtains information about a filetype based


mimeinfo_from_type($element, $mimetype) on the MIME type rather than the other way
around.

Obtains information about a filetype based


on its extension. Will use a default if no
mimeinfo($element, $filename)
information is present about that particular
extension.

get_mimetypes_array()
@return List of information about file
types based on extensions.

Fetches content of file from Internet (using


download_file_content($url,
proxy if defined). Uses cURL extension if
$headers=null,$postdata=null,
present.
$fullresponse=false, $timeout=300,
$connecttimeout=20,
Due to security concerns only downloads from
$skipcertverify=false)
http(s) sources are supported.

Depending on the $path of the file and $type


(whether it is rss, user, group file, etc)
and $options (with key and value) is added
get_file_url($path,$options=null,
to url.
$type='coursefile')
All the combination is done and url is
designed and send back

define('BYTESERVING_BOUNDARY', 's1k2o3d4a5k6s7'); //unique string constant

Useful Resources
 http://docs.moodle.org/en/Development:Blocks
 http://dev.moodle.org/mod/resource/view.php?id=48
 http://docs.moodle.org/en/Development_talk:Blocks
Similarly for Modules
 http://docs.moodle.org/en/Development:Modules

You might also like