2017 © Pedro Peláez
 

library filemanager

image

hiokwee/filemanager

  • Sunday, June 18, 2017
  • by hiokwee
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Filemanager

methods

  1. File (string $_target_dir)
    *$_target_dir*    The target directory where the files will be saved, (*1)

  2. upload (string $param_name) : boolean
    $param_name    The HTML form input field name, (*2)

  3. delFileByName (string $name) : boolean
    $name    Name of the file, (*3)

  4. getFileByName (string $name) : boolean
    $name    Name of the file, (*4)

  5. getFileList () : string
    , (*5)

  6. getTargetFolder () : string
    , (*6)

  7. setAllowedExtensions (array<mixed,string> $extensions)
    $extensions    The permitted extension types, (*7)

  8. setOnlyAllowImage (boolean $image_only)
    $image_only    Permit only image file types, (*8)

  9. setMaxFileSize (integer $max_file_size)
    $max_file_size    Maximum permitted file size in bytes, (*9)

  10. setScanFile (boolean $scan_file)
    $scan_file    Enable anti-virus file scan
    , (*10)

example

$fm = new File("uploads/");
$fm->setAllowedExtensions(["PNG", "GIF", "TXT"]);
$fm->setOnlyAllowImage(true);
$fm->setMaxFileSize(5120);
$fm->setScanFile(true);

if (isset($_POST["act"])) {

        // upload file
        if ($_POST["act"] === "upload") {
                try {
                        $fm->upload("fileToUpload");
                }
                catch (Exception $e) {
                }
        }

        // download file by name
        elseif ($_POST["act"] === "download") {
                if (isset($_POST["filename"])) {
                        try {
                                $fm->getFileByName($_POST["filename"]);
                        }
                        catch (Exception $e) {
                        }
                }
        }

        // delete file by name
        elseif ($_POST["act"] === "delete") {
                if (isset($_POST["filename"])) {
                        try {
                                $fm->delFileByName($_POST["filename"]);
                        }
                        catch (Exception $e) {
                        }
                }
        }
}

The Versions

18/06 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires