PHP code example of jairojeffsantos / easy-file-uploader
1. Go to this page and download the library: Download jairojeffsantos/easy-file-uploader 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/ */
jairojeffsantos / easy-file-uploader example snippets
use EasyFileUploader\FileUploader;
$uploader = new FileUploader();
$result = $uploader->uploadFile(
__DIR__ . '/uploads', // Target directory
$_FILES['file'], // File from form
['image/jpeg', 'image/png', 'application/pdf'], // Allowed MIME types
5 // Max file size in MB
);
print_r($result);
/*
Possible return (success):
Array
(
[status] => success
[message] => File uploaded successfully.
[file_path] => /your/project/uploads/file_643f3a9c8e2d0.png
)
Possible return (error):
Array
(
[status] => format_not_allowed
[message] => File type not allowed.
)
Array
(
[status] => max_file_size_exceeded
[message] => File exceeds the limit of {$maxSize} MB.
)
*/