microphork/package-uploads

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

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

dev-master 2019-03-14 01:07 UTC

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