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