PHP code example of wsw / simple-upload
1. Go to this page and download the library: Download wsw/simple-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/ */
wsw / simple-upload example snippets
php
use League\Flysystem\Adapter\Local;
use WSW\SimpleUpload\Services\SimpleUpload;
try {
$adapter = new Local('/home/files');
$file = SimpleUpload::create($_FILES['file'], $adapter)->send();
} catch (\Exception $e) {
echo $e->getMessage();
}
php
// Returns the size of the file in KB
echo $file->getSize(); // 94762
// Returns the file type
echo $file->getMimetype(); // text/plain
// Returns instance of DateTime for date and time of creation
echo $file->getTimestamp(); // \DateTime
// Absolute file path
echo $file->getPath(); // /home/files/file.txt
// Directory where the file is located
echo $file->getFilePath(); // /home/files/
// Filename with extension
echo $file->getFileName(); // file.txt
// Filename without extension
echo $file->getName(); // file
// File extension
echo $file->getExtension(); // txt