dolibarr 19.0.3
frmupload.php
1<?php
2/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
4 *
5 * Source modified from part of fckeditor (http://www.fckeditor.net)
6 * retrieved as GPL v2 or later
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22define('NOTOKENRENEWAL', 1); // Disables token renewal
23
24// Load Dolibarr environment
25require '../../../../main.inc.php';
26
28
29?>
30<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
31<!--
32 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
33 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
34 *
35 * == BEGIN LICENSE ==
36 *
37 * Licensed under the terms of any of the following licenses at your
38 * choice:
39 *
40 * - GNU General Public License Version 2 or later (the "GPL")
41 * https://www.gnu.org/licenses/gpl.html
42 *
43 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
44 * https://www.gnu.org/licenses/lgpl.html
45 *
46 * - Mozilla Public License Version 1.1 or later (the "MPL")
47 * http://www.mozilla.org/MPL/MPL-1.1.html
48 *
49 * == END LICENSE ==
50 *
51 * Page used to upload new files in the current folder.
52-->
53<html>
54 <head>
55 <title>File Upload</title>
56 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
57<?php
58print '<!-- Includes CSS for Dolibarr theme -->'."\n";
59// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
60$themepath = dol_buildpath($conf->css, 1);
61$themesubdir = '';
62if (!empty($conf->modules_parts['theme'])) { // This slow down
63 foreach ($conf->modules_parts['theme'] as $reldir) {
64 if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
65 $themepath = dol_buildpath($reldir.$conf->css, 1);
66 $themesubdir = $reldir;
67 break;
68 }
69 }
70}
71
72//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
73print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
74?>
75 <link href="browser.css" type="text/css" rel="stylesheet" >
76 <script type="text/javascript" src="js/common.js"></script>
77 <script type="text/javascript">
78
79function SetCurrentFolder( resourceType, folderPath )
80{
81 var sUrl = oConnector.ConnectorUrl + 'Command=FileUpload' ;
82 sUrl += '&Type=' + resourceType ;
83 sUrl += '&CurrentFolder=' + encodeURIComponent( folderPath );
84
85 document.getElementById('frmUpload').action = sUrl ;
86}
87
88function OnSubmit()
89{
90 console.log("Click on OnSubmit");
91 if ( document.getElementById('NewFile').value.length == 0 )
92 {
93 alert( 'Please select a file from your computer' );
94 return false ;
95 }
96
97 // Set the interface elements.
98 document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder (Upload in progress, please wait...)' ;
99 document.getElementById('btnUpload').disabled = true ;
100
101 return true ;
102}
103
104function OnUploadCompleted( errorNumber, data )
105{
106 console.log("errorNumber = "+errorNumber);
107
108 // Reset the Upload Worker Frame.
109 window.parent.frames['frmUploadWorker'].location = 'javascript:void(0)' ;
110
111 // Reset the upload form (On IE we must do a little trick to avoid problems).
112 if ( document.all )
113 document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
114 else
115 document.getElementById('frmUpload').reset();
116
117 // Reset the interface elements.
118 document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
119 document.getElementById('btnUpload').disabled = false ;
120
121 switch ( errorNumber )
122 {
123 case 0:
124 window.parent.frames['frmResourcesList'].Refresh();
125 break;
126 case 1: // Custom error.
127 alert( data );
128 break;
129 case 201:
130 window.parent.frames['frmResourcesList'].Refresh();
131 alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + data + '"' );
132 break;
133 case 202:
134 alert( 'Invalid file (Bad extension)' );
135 break;
136 default:
137 alert( 'Error on file upload. Error number: ' + errorNumber );
138 break;
139 }
140}
141
142window.onload = function()
143{
144 window.top.IsLoadedUpload = true ;
145}
146 </script>
147 </head>
148 <body>
149 <form id="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
150 <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
151 <table class="fullHeight" cellspacing="0" cellpadding="0" width="100%" border="0">
152 <tr>
153 <td class="nowrap valignmiddle">
154 <table width="100%" class="inline-block valignmiddle">
155 <tr>
156 <td><input id="NewFile" name="NewFile" type="file"></td>
157 <td class="nowrap">&nbsp;<input id="btnUpload" type="submit" value="Upload" class="flat button"></td>
158 </tr>
159 </table>
160 <!-- Section for upload result message -->
161 <span id="eUploadMessage"></span><br>
162 </td>
163 </tr>
164 </table>
165 </form>
166 </body>
167</html>
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:121
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124