Gere les problemes lors de l'upload de fichiers dans le browser
Fix #1541
This commit is contained in:
parent
7411bb9bac
commit
8851af00df
|
@ -184,10 +184,9 @@ if (isset($error) && $error) echo "<p class=\"alert alert-danger\">$error</p>";
|
||||||
|
|
||||||
<?php __("Send one file:"); ?><br />
|
<?php __("Send one file:"); ?><br />
|
||||||
<input class="int" name="userfile" type="file" />
|
<input class="int" name="userfile" type="file" />
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" /><?php ### WTF ???? ?>
|
|
||||||
<br />
|
<br />
|
||||||
<input type="submit" id="sendthisfile" class="ina" value="<?php __("Send this file"); ?>" />
|
<input type="submit" id="sendthisfile" class="ina" value="<?php __("Send this file"); ?>" />
|
||||||
<?php echo sprintf(_("Warning: max size: %s"),ini_get('upload_max_filesize')); ?>
|
<?php echo sprintf(_("Warning: max size: %s"),$bro->getMaxAllowedUploadSize() ); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -547,7 +547,7 @@ class m_bro {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!strpos($_FILES['userfile']['name'],"/")) {
|
if (!strpos($_FILES['userfile']['name'],"/")) {
|
||||||
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
|
if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['userfile']['tmp_name'])) {
|
||||||
if (!file_exists($absolute."/".$_FILES['userfile']['name'])) {
|
if (!file_exists($absolute."/".$_FILES['userfile']['name'])) {
|
||||||
@touch($absolute."/".$_FILES['userfile']['name']);
|
@touch($absolute."/".$_FILES['userfile']['name']);
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,23 @@ class m_bro {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$err->log("bro","uploadfile","Tentative d'attaque : ".$_FILES['userfile']['tmp_name']);
|
// there was an error, raise it
|
||||||
|
$err->log("bro","uploadfile","Problem when uploading a file");
|
||||||
|
switch ( $_FILES['userfile']['error'] ) {
|
||||||
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
|
$erstr=_("The uploaded file exceeds the max file size allowed");
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
|
case UPLOAD_ERR_PARTIAL:
|
||||||
|
case UPLOAD_ERR_NO_FILE:
|
||||||
|
case UPLOAD_ERR_NO_TMP_DIR:
|
||||||
|
case UPLOAD_ERR_CANT_WRITE:
|
||||||
|
case UPLOAD_ERR_EXTENSION:
|
||||||
|
default:
|
||||||
|
$erstr=_("Undefined error ").$_FILES['userfile']['error'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$err->raise("bro",_("Error during the upload of the file: ").$erstr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1049,6 +1065,9 @@ class m_bro {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMaxAllowedUploadSize() {
|
||||||
|
return min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
|
||||||
|
}
|
||||||
|
|
||||||
} /* Class Browser */
|
} /* Class Browser */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue