Fix max size

This commit is contained in:
Laurent Destailleur 2018-11-06 17:40:59 +01:00
parent 52aa860008
commit 7e33af6677
2 changed files with 24 additions and 1 deletions

View File

@ -40,6 +40,7 @@ $langs->loadLangs(array("errors","admin","modulebuilder"));
$mode=GETPOST('mode', 'alpha');
if (empty($mode)) $mode='common';
$action=GETPOST('action','alpha');
//var_dump($_POST);exit;
$value=GETPOST('value', 'alpha');
$page_y=GETPOST('page_y','int');
$search_keyword=GETPOST('search_keyword','alpha');
@ -1003,8 +1004,29 @@ if ($mode == 'deploy')
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print '<input type="hidden" name="mode" value="deploy">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print $langs->trans("YouCanSubmitFile");
$max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1;
if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024;
if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024;
// Now $max and $maxphp are in Kb
$maxmin = $max;
if ($maxphp > 0) $maxmin=min($max,$maxphp);
if ($maxmin > 0)
{
// MAX_FILE_SIZE doit précéder le champ input de type file
print '<input type="hidden" name="max_file_size" value="'.($maxmin*1024).'">';
}
print '<input class="flat minwidth400" type="file" name="fileinstall"> ';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
print '<br>';

View File

@ -127,6 +127,7 @@ class FormFile
if ($maxmin > 0)
{
// MAX_FILE_SIZE doit précéder le champ input de type file
$out .= '<input type="hidden" name="max_file_size" value="'.($maxmin*1024).'">';
}