PHP code example of yuqinglan / upload
1. Go to this page and download the library: Download yuqinglan/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/ */
yuqinglan / upload example snippets
hangjian\upload\UploadFile;
$upload = new UploadFile();
$upload->maxSize = 1*1024*1024; // 默认为-1,不限制上传大小
$upload->savePath = './upload/'; // 上传根目录
$upload->saveRule = 'uniqid'; // 上传文件的文件名保存规则
$upload->uploadReplace = true; // 如果存在同名文件是否进行覆盖
$upload->autoSub = true; // 上传子目录开启
$upload->subType = 'date'; // 上传子目录命名规则
$upload->allowExts = ['jpg', 'png']; // 允许类型
if ($upload->upload()) {
var_dump($upload->getUploadFileInfo());
} else {
var_dump($upload->getErrorMsg());
}