PHP code example of coderatio / uploadia

1. Go to this page and download the library: Download coderatio/uploadia 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/ */

    

coderatio / uploadia example snippets


// OR
adia = new Coderatio\Uploadia\Uploadia();
$uploadia->setDir('uploads')
    ->setExtensions(['jpg', 'png', 'jpeg', 'gif'])
    ->setMaxSize(1); // In megabytes. 1MB
    
// There are several methods to use. e.g $uploadia->allowAllFormats()
// $uploadia->sameName($bool) takes a boolean. e.t.c
    
if($uploadia->uploadFile('photo') {
     // photo is the file input name.
     // Get the uploaded file name or get error message.
     
     $uploadia->getUploadName(); // Returns uploaded file name;
     $uploadia->getMessage(); // Returns error messages
}