Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [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: 324 lines (13 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($saveasfilename, $maxbytes)   X-Ref
Process uploaded file

return: array|bool

process_upload($saveasfilename, $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 $saveasfilename 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