25if (!defined(
'NOREQUIREMENU')) {
26 define(
'NOREQUIREMENU',
'1');
28if (!defined(
'NOREQUIREHTML')) {
29 define(
'NOREQUIREHTML',
'1');
31if (!defined(
'NOREQUIREAJAX')) {
32 define(
'NOREQUIREAJAX',
'1');
34if (!defined(
'NOREQUIRESOC')) {
35 define(
'NOREQUIRESOC',
'1');
39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/fileupload.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
53$element =
GETPOST(
'element',
'alpha');
54$elementupload = $element;
57$object = fetchObjectByElement($id, $element);
65if (!is_object($object) || empty(
$object->id) || empty(
$object->module)) {
66 dol_syslog(
"fileupload.php object ".$element.
" with id ".
$id.
" was not found or its element is not supported", LOG_WARNING);
73$usesublevelpermission = ($module != $element ? $element :
'');
74if ($usesublevelpermission && !$user->hasRight($module, $element)) {
75 $usesublevelpermission =
'';
81if (!empty($user->socid)) {
82 $socid = $user->socid;
85 if (property_exists($object,
'socid') && !empty(
$object->socid) && $socid !=
$object->socid) {
88 dol_syslog(
"fileupload.php object ".$element.
" with id ".
$id.
" belongs to another third party than the external user", LOG_WARNING);
96 dol_syslog(
"fileupload.php not allowed by restrictedArea (module=".
$object->module.
" table_element=".
$object->table_element.
")", LOG_WARNING);
107header(
'Pragma: no-cache');
108header(
'Cache-Control: no-store, no-cache, must-revalidate');
109header(
'Content-Disposition: inline; filename="files.json"');
110header(
'X-Content-Type-Options: nosniff');
112header(
'Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
113header(
'Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
115switch ($_SERVER[
'REQUEST_METHOD']) {
128 $upload_handler =
new FileUpload(
null, $id, $elementupload);
133 if (isset($_SERVER[
'HTTP_ACCEPT']) && (strpos($_SERVER[
'HTTP_ACCEPT'],
'application/json') !==
false)) {
134 header(
'Content-type: application/json');
136 header(
'Content-type: text/plain');
138 echo json_encode(array(array(
'name' =>
'',
'error' => $e->getMessage())));
147 $upload_handler->post();
156 header(
'HTTP/1.0 405 Method Not Allowed');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
This class is used to manage file upload using ajax.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
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.