Overview
Comment: | Limiter la taille des blobs |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA1: |
1c806672282b5dc7c7c9b934b0d7114b |
User & Date: | bohwaz on 2020-02-29 23:15:57 |
Other Links: | manifest | tags |
Context
2020-04-07
| ||
00:36 | Fix import comptable avec le nom du moyen de paiement à la place du code check-in: 7e67be9f3d user: bohwaz tags: trunk, stable | |
2020-02-29
| ||
23:17 | Merge avec trunk check-in: 22c90a3c3f user: bohwaz tags: dev | |
23:15 | Limiter la taille des blobs check-in: 1c80667228 user: bohwaz tags: trunk, stable | |
2020-02-28
| ||
02:01 | Correctif : renvoi de valeurs booléennes pour les filtres booléens check-in: 5d9609e682 user: bohwaz tags: trunk, stable | |
Changes
Modified src/include/lib/Garradin/Fichiers.php from [0354ffcea4] to [2575ef0c54].
︙ | ︙ | |||
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | throw new UserException('Fichier reçu invalide : vide ou sans nom de fichier.'); } if (!is_uploaded_file($file['tmp_name'])) { throw new \RuntimeException('Le fichier n\'a pas été envoyé de manière conventionnelle.'); } $name = preg_replace('/\s+/', '_', $file['name']); $name = preg_replace('/[^\d\w._-]/ui', '', $name); return self::storeFile($name, $file['tmp_name']); } /** * Upload de fichier à partir d'une chaîne en base64 * @param string $name * @param string $content * @return Fichiers */ | > > > > > > > > > > > > > > > > > > > > > > > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | throw new UserException('Fichier reçu invalide : vide ou sans nom de fichier.'); } if (!is_uploaded_file($file['tmp_name'])) { throw new \RuntimeException('Le fichier n\'a pas été envoyé de manière conventionnelle.'); } $max_blob_size = self::getMaxBlobSize(); // Vérifier que le fichier peut rentrer en base de données (dans PHP < 7.2 on n'utilise pas openBlob) if (null !== $max_blob_size && $file['size'] > $max_blob_size) { unlink($file['tmp_name']); throw new UserException('Taille du fichier supérieure au maximum autorisé en base de données'); } $name = preg_replace('/\s+/', '_', $file['name']); $name = preg_replace('/[^\d\w._-]/ui', '', $name); return self::storeFile($name, $file['tmp_name']); } /** * Returns the maximum value size that can be handled by a bindValue * @return null|integer */ static public function getMaxBlobSize() { $memory_limit = Utils::return_bytes(ini_get('memory_limit')); if (!$memory_limit) { return null; } return round(($memory_limit - memory_get_usage()) * 0.9); } /** * Upload de fichier à partir d'une chaîne en base64 * @param string $name * @param string $content * @return Fichiers */ |
︙ | ︙ |