直接使用方法的 Upload($uploadimgfile)
就可以实现上传和压缩操作。
<?php
namespace Home\Controller;
final class Upload
{
//设置文件保存目录
public $uploaddir = "Public/uploadimg/";
//设置允许上传文件的类型
public $type=array("jpg","gif","bmp","jpeg","png");
//获取文件后缀名函数
public function fileext($filename)
{
return substr(strrchr($filename, '.'), 1);
}
//生成随机文件名函数
public function random($length)
{
$hash = 'CRP-'.date("mis");
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++)
{
$h