ILIAS  release_7 Revision v7.30-3-g800a261c036
with_custom_file_metadata.php File Reference

Go to the source code of this file.

Functions

 with_custom_file_metadata ()
 

Function Documentation

◆ with_custom_file_metadata()

with_custom_file_metadata ( )

Definition at line 2 of file with_custom_file_metadata.php.

3{
4 global $DIC;
5 $factory = $DIC->ui()->factory();
6 $renderer = $DIC->ui()->renderer();
7
8 // Handle a file upload ajax request
9 if (isset($_GET['example']) && $_GET['example'] == 2) {
10 $upload = $DIC->upload();
11 try {
12 $upload->process();
13 // $upload->moveFilesTo('/myPath/'); // Since we are in an example here, we do not move the files. But this would be the way wou move files using the FileUpload-Service
14
15 // Access the custom file name and description via $_POST parameters:
16 // $_POST['customFileName'] and $_POST['fileDescription']
17
18 // The File-Dropzones will expect a valid json-Status (success true or false).
19 echo json_encode(['success' => true, 'message' => 'Successfully uploaded file']);
20 } catch (\Exception $e) {
21 // See above
22 echo json_encode(['success' => false, 'message' => $e->getMessage()]);
23 }
24 exit();
25 }
26
27 $uploadUrl = $_SERVER['REQUEST_URI'] . '&example=2';
28 $dropzone = $factory->dropzone()->file()->standard($uploadUrl)
29 ->withUserDefinedFileNamesEnabled(true)
30 ->withUserDefinedDescriptionEnabled(true)
31 ->withUploadButton($factory->button()->standard('Upload', ''));
32
33 return $renderer->render($dropzone);
34}
$_GET["client_id"]
global $DIC
Definition: goto.php:24
exit
Definition: login.php:29
$factory
Definition: metadata.php:58
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10

References $_GET, $_SERVER, $DIC, Vendor\Package\$e, $factory, and exit.