microphork / package-uploads
A file uploader package for the microphork framework
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:microphork-package
Requires
This package is not auto-updated.
Last update: 2021-12-25 01:18:33 UTC
README
This is a file uploader package for the microphork framework. It validates and saves files uploaded via POST.
To extend this package create a \Phork\App\Uploads
class in the app/classes
folder.
Usage
//print a simple upload form
\Phork::output()->addContent('
<form enctype="multipart/form-data" method="post">
<input name="upload" type="file" />
<button type="submit">submit</button>
</form>
');
//load and alias a new uploads package
class_alias(\Phork::instance()->initPackage('Uploads'), 'PhorkUploads');
//if a file was uploaded then save it
if (\Phork::router()->getMethod() == 'post' && $files = \PhorkUploads::getFiles()) {
if (!empty($files['upload']) && $file = $files['upload']) {
//uploaded $file['name'] to $file['tmp_name'] and move it to $output
\PhorkUploads::saveFile($file['tmp_name'], $output = LOG_PATH.'upload.demo', true);
}
}
Credits
Built by Elenor at Phork Labs.
License
Licensed under The MIT License http://www.opensource.org/licenses/mit-license.php