1. Go to this page and download the library: Download willry/uploader 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/ */
willry / uploader example snippets
illRy\Uploader\Image;
use WillRy\Uploader\File;
use WillRy\Uploader\Send;
if ($_POST && !empty($_GET["default"])) {
$path = $_FILES['file']['name'];
$extension = pathinfo($path, PATHINFO_EXTENSION);
//it's an image
$isImage = Image::isAllowed($extension);
//it's an commom file
$isFile = File::isAllowed($extension);
if ($isImage) {
//cropper
$maxWidth = 500;
//optional
//jpg -> 0% ~ 100%
//png -> 0 ~ 9
$quality = ["jpg" => 75, "png" => 5];
$image = new Image("uploads");
$filePath = $image->upload($_FILES["file"], $_POST['file_name'], $maxWidth, $quality);
} elseif ($isFile) {
$file = new File("uploads");
$filePath = $file->upload($_FILES["file"], $_POST['file_name']);
} else {
throw new Exception("Invalid mime type or extension");
}
var_dump($filePath);
}
if ($_POST && !empty($_GET["custom"])) {
$tiposDeExtensao = ["csv"];
$send = new Send("uploads", $tiposDeExtensao);
$filePath = $send->upload($_FILES["file"], $_POST['file_name']);
var_dump($filePath);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.