Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

A file uploader package for the microphork framework.

Notifications You must be signed in to change notification settings

phork/microphork-package-uploads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

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

About

A file uploader package for the microphork framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages