ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
with_custom_file_metadata.php
Go to the documentation of this file.
1 <?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 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$factory
Definition: metadata.php:47
with_custom_file_metadata()