//产品多图片上传
public function index(){
$typeArr = array("jpg", "png", "gif");//允许上传文件格式
$path = "./uploads/img/";//上传路径
if (isset($_POST)) {
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$name_tmp = $_FILES['file']['tmp_name'];
if (empty($name)) {
echo json_encode(array("error"=>"您还未选择图片"));exit;
}
$type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型
if (!in_array($type, $typeArr)) {
echo json_encode(array("error"=>"请上传jpg,png或gif类型的图片!"));exit;
}
if ($size > (2*1024*1024)) {
echo json_encode(array("error"=>"图片大小已超过2MB!"));exit;
}
$image = \think\Image::open(request()->file('file&
PHP后台图片的等比缩放
最新推荐文章于 2023-02-02 16:18:13 发布