Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

This plugin is used to upload files

Copyright: 2010 Dongsheng Cai {@link http://dongsheng.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 302 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

repository_upload:: (7 methods):
  print_login()
  upload()
  process_upload()
  check_valid_contents()
  get_listing()
  supported_returntypes()
  contains_private_data()


Class: repository_upload  - X-Ref

A repository plugin to allow user uploading files

print_login()   X-Ref
Print a upload form

return: array

upload($saveas_filename, $maxbytes)   X-Ref
Process uploaded file

return: array|bool

process_upload($saveas_filename, $maxbytes, $types = '*', $savepath = '/', $itemid = 0,$license = null, $author = '', $overwriteexisting = false, $areamaxbytes = FILE_AREA_MAX_BYTES_UNLIMITED)   X-Ref
Do the actual processing of the uploaded file

param: string $saveas_filename name to give to the file
param: int $maxbytes maximum file size
param: mixed $types optional array of file extensions that are allowed or '*' for all
param: string $savepath optional path to save the file to
param: int $itemid optional the ID for this item within the file area
param: string $license optional the license to use for this file
param: string $author optional the name of the author of this file
param: bool $overwriteexisting optional user has asked to overwrite the existing file
param: int $areamaxbytes maximum size of the file area.
return: object containing details of the file uploaded

check_valid_contents($filepath)   X-Ref
Checks the contents of the given file is not completely NULL - this can happen if a
user drags & drops a folder onto a filemanager / filepicker element

param: string $filepath full path (including filename) to file to check
return: true if file has at least one non-null byte within it

get_listing($path = '', $page = '')   X-Ref
Return a upload form

return: array

supported_returntypes()   X-Ref
supported return types

return: int

contains_private_data()   X-Ref
Is this repository accessing private data?

return: bool