Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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: 304 lines (12 kb)
Included or required:0 times
Referenced: 1 time
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