dolibarr
16.0.5
Main Page
Related Pages
Modules
Classes
Files
Examples
File List
File Members
dolibarr_16.0
htdocs
core
ajax
fileupload.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@inodbox.com>
3
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
24
if
(!defined(
'NOCSRFCHECK'
)) {
25
define(
'NOCSRFCHECK'
,
'1'
);
26
}
27
if
(!defined(
'NOTOKENRENEWAL'
)) {
28
define(
'NOTOKENRENEWAL'
,
'1'
);
29
}
30
if
(!defined(
'NOREQUIREMENU'
)) {
31
define(
'NOREQUIREMENU'
,
'1'
);
// If there is no menu to show
32
}
33
if
(!defined(
'NOREQUIREHTML'
)) {
34
define(
'NOREQUIREHTML'
,
'1'
);
// If we don't need to load the html.form.class.php
35
}
36
37
38
require
'../../main.inc.php'
;
39
require_once DOL_DOCUMENT_ROOT.
'/core/class/fileupload.class.php'
;
40
41
error_reporting(E_ALL | E_STRICT);
42
43
//print_r($_POST);
44
//print_r($_GET);
45
//print 'upload_dir='.GETPOST('upload_dir');
46
47
$fk_element =
GETPOST
(
'fk_element'
,
'int'
);
48
$element =
GETPOST
(
'element'
,
'alpha'
);
49
50
51
$upload_handler =
new
FileUpload
(
null
, $fk_element, $element);
52
53
header(
'Pragma: no-cache'
);
54
header(
'Cache-Control: no-store, no-cache, must-revalidate'
);
55
header(
'Content-Disposition: inline; filename="files.json"'
);
56
header(
'X-Content-Type-Options: nosniff'
);
57
header(
'Access-Control-Allow-Origin: *'
);
58
header(
'Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE'
);
59
header(
'Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'
);
60
61
switch
($_SERVER[
'REQUEST_METHOD'
]) {
62
case
'OPTIONS'
:
63
break
;
64
case
'HEAD'
:
65
case
'GET'
:
66
$upload_handler->get();
67
break
;
68
case
'POST'
:
69
if
(isset($_REQUEST[
'_method'
]) && $_REQUEST[
'_method'
] ===
'DELETE'
) {
70
$upload_handler->delete();
71
}
else
{
72
$upload_handler->post();
73
}
74
break
;
75
case
'DELETE'
:
76
$upload_handler->delete();
77
break
;
78
default
:
79
header(
'HTTP/1.0 405 Method Not Allowed'
);
80
exit;
81
}
82
83
$db->close();
FileUpload
This class is used to manage file upload using ajax.
Definition:
fileupload.class.php:31
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition:
functions.lib.php:484
Generated on Sat Jun 3 2023 01:01:02 for
dolibarr
by Doxygen 1.8.17