FIle Uploader is a php package to aid fast , easy and safe file upload
FIle Uploader is a php package to aid fast , easy and safe file upload
composer require codad5/file-helper
index.php
<form action="./upload.php" method='post' enctype="multipart/form-data">
<input type="file" name="test[]" multiple>
<input value="submit" type="submit">
</form>
upload.php
<?php
include(__DIR__ . '/../vendor/autoload.php');
$file_upload_controller = new Codad5\FileHelper\FileUploader('test', "uploads/");
test
- the name given to the $_FILES
array by default - for refrence $_FILES['test
]`
uploads/
- Upload path relative to upload.php
#any other extension aid the given will give error or ignored depending on your error settings
$file_upload_controller->add_ext('svg', 'png');
# for unique id can be replaced with uniqid('', true)
$file_upload_controller->set_prefix('my prefix');
$file_upload_controller->set_sizes(10000, 20);
10000
- This is the maximum file size allowed, to ignore for your .ini
config set it to null
20
- This is the minimum file size allowed default equals 0
/**
* This is use to turn on and off reporting of the upload process
* @param bool $file_error - to report error imbound in file from request if `true` else ignore
* @param bool $size_error - TO report size related error if `true` else ignore
* @param bool $type_error - To report error related to file type if `true` else ignore
*/
$file_upload_controller->set_reporting(true, false, true);
$file_error
is to report error imbounded in file from request as found in $_SERVER['test']
$size_error
is to report size related error depending on your settings$type_error
is to report error if a file is not part of the allowed fileNOTE: If any is
false
and error is found it will ignore the file and continue upload with out the file
$file_upload_controller->move_files();
$upload_path = $file_upload_controller->get_uploads();
foreach ($upload_path as $key => $value) {
# code...
echo "This file has been uploaded to ".$value['uploaded_path']."<br/>;
}
uploaded_path
- The final uploaded file with path relative to the script tag upload.php
name
- The name of the filesize
- The size of the filetype
- The file Typeext
- The file extension
$file_upload_controller = new \Codad5\FileHelper\FileUploader('tes', "uploads/");
$uploaded_file_array = $file_upload_controller
->set_reporting(false, false, false)
->add_ext('png', 'pdf')
->set_prefix('cool Stuff')
->move_files()
->get_uploads();
foreach ($uploaded_file_array as $key => $value) {
# code...
echo "This file has been uploaded to ".$value['uploaded_path']."<br/>";
}
This documentaion will be updated in time as the project grows for enquire and more information contact me here
Built with 💗 by Chibueze Michael A.