PHP code example of it-empower-solutions / secure-upload
1. Go to this page and download the library: Download it-empower-solutions/secure-upload library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
it-empower-solutions / secure-upload example snippets
use ItEmpower\SecureUpload\UploadValidator;
$validator = new UploadValidator([
'max_size' => 5 * 1024 * 1024,
'allowed_extensions' => ['jpg', 'jpeg', 'png', 'pdf'],
]);
$result = $validator->validateUploadedFile($_FILES['document'] ?? []);
if (!$result->isValid()) {
foreach ($result->errors as $error) {
echo "{$error->code}: {$error->message}\n";
}
} else {
echo $result->safeFilename;
// Déplacez ou stockez vous-même le fichier après validation.
}