Functions Related to file from filelib.

Function Name

Modifies the content of the uploaded file by adding html headers and giving some look and feel to the uploaded file text. Send requested byte range of file. Improves memory consumption and works around 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 content then delete it. If $location does not exist to start, that is not considered an error. Write all the records into CSV file. Retrieve all the records from the CSV file and if $table exist than return all the $row[] to the form. Handles the sending of file data to the user's browser, including support for byteranges etc. Call internally by send_temp_file() function to remove the instance of the file from temp folder. Handles the sending of temporary file to user, download is forced. File is deleted after abort or successful sending. Obtains descriptions for file types (e.g. 'Microsoft Word document') from the mimetypes.php language file. Checks for other type which are having no header description like ‘application/pdf’ format.

byteserving_send_file($filename, $mimetype, $ranges) readfile_chunked($filename, $retbytes=true)


put_records_csv($file, $records, $table = NULL)

get_records_csv($file, $table)

send_file($path,$filename,$lifetime= 'default',$filter=0,$pathisstring=false, $forcedownload=false, $mimetype='')


send_temp_file($path, $filename, $pathisstring=false)

get_mimetype_description($mimetype, $capitalise=false)

mimeinfo_from_icon($element, $icon)

Get information about a filetype based on the icon file. Obtains information about a filetype based 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 information is present about that particular extension.

mimeinfo_from_type($element, $mimetype)

mimeinfo($element, $filename)



List of information types based on extensions.



download_file_content($url, $headers=null,$postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false)

Fetches content of file from Internet (using proxy if defined). Uses cURL extension if present. Due to security concerns only downloads from 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 to url. All the combination is designed and send back done and url is

get_file_url($path,$options=null, $type='coursefile')

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

Useful Resources    Similarly for Modules

Sign up to vote on this title
UsefulNot useful