24if (!defined(
'NOREQUIREMENU')) {
25 define(
'NOREQUIREMENU',
'1');
27if (!defined(
'NOREQUIREHTML')) {
28 define(
'NOREQUIREHTML',
'1');
30if (!defined(
'NOREQUIREAJAX')) {
31 define(
'NOREQUIREAJAX',
'1');
33if (!defined(
'NOREQUIRESOC')) {
34 define(
'NOREQUIRESOC',
'1');
38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/fileupload.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
43$id =
GETPOST(
'fk_element',
'int');
44$element =
GETPOST(
'element',
'alpha');
45$elementupload = $element;
50$module = $object->module;
51$element = $object->element;
53$usesublevelpermission = ($module != $element ? $element :
'');
54if ($usesublevelpermission && !$user->hasRight($module, $element)) {
55 $usesublevelpermission =
'';
61if (!empty($user->socid)) {
62 $socid = $user->socid;
63 if (!empty($object->socid) && $socid != $object->socid) {
68$result =
restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission,
'fk_soc',
'rowid', 0, 1);
70 httponly_accessforbidden(
'Not allowed by restrictArea (module='.$object->module.
' table_element='.$object->table_element.
')');
78$upload_handler =
new FileUpload(
null, $id, $elementupload);
83header(
'Pragma: no-cache');
84header(
'Cache-Control: no-store, no-cache, must-revalidate');
85header(
'Content-Disposition: inline; filename="files.json"');
86header(
'X-Content-Type-Options: nosniff');
88header(
'Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
89header(
'Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
91switch ($_SERVER[
'REQUEST_METHOD']) {
96 $upload_handler->get();
99 if (isset($_REQUEST[
'_method']) && $_REQUEST[
'_method'] ===
'DELETE') {
100 $upload_handler->delete();
102 $upload_handler->post();
107 $upload_handler->delete();
110 header(
'HTTP/1.0 405 Method Not Allowed');
This class is used to manage file upload using ajax.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
fetchObjectByElement($element_id, $element_type, $element_ref='')
Fetch an object from its id and element_type Inclusion of classes is automatic.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.