PHP code example of karelwintersky / arris.php-file-upload

1. Go to this page and download the library: Download karelwintersky/arris.php-file-upload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

karelwintersky / arris.php-file-upload example snippets


use Arris\Toolkit\FileUpload;

if (isset($_FILES["file"])) {
    $upload = new FileUpload($_FILES["file"]);
    $upload->setAllowedExtensions(array("png", "jpg", "jpeg", "gif"));
    $upload->setMaxSize(5); // in MB
    $upload->setPath("upload/files");
    $upload->setName("foo");
    
    if (! $upload->upload()) {
        echo "Upload error: " . $upload->getError();
    } else {
        echo "Upload successful!";
    }
}

use Arris\Toolkit\FileUpload;

if (isset($_FILES["file"])) {
    $upload = (new FileUpload($_FILES["file"]))->setMaxSize(20)->setPath("upload/files")->encrypt_name();
    
    if (! $upload->upload()) {
        echo "Upload error: " . $upload->getError();
    } else {
        echo "Upload successful!";
    }
}

composer