承接 yanli0303/yii-uploaded-file 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yanli0303/yii-uploaded-file

最新稳定版本:v0.1

Composer 安装命令:

composer require yanli0303/yii-uploaded-file

包简介

A wrapper for CUploadedFile class of PHP Yii framework.

README 文档

README

By Yan Li

Build Status Coverage Status License PayPayl donate button

A wrapper for CUploadedFile class of PHP Yii framework. It adds following help methods to CUploadedFile class:

  • isExtensionInList($extensions)
  • isMimeTypeInList($mimeTypes)
  • isImageTypeInList($imageTypes)
  • validateImageDimensions($maxWidth, $maxHeight, $minWidth, $minHeight)
  • validate($maxFileBytes, $allowedExtensions, $allowedMimeTypes)
  • validateImage($maxFileBytes, $allowedExtensions, $allowedImageTypes, $maxWidth = null, $maxHeight = null, $minWidth = null, $minHeight = null)
  • saveImage($saveAs, $pngToJpg = false)

Usage

$maxBytes = 4194304; //4 * 1024 * 1024 = 4MB
$allowedExtensions = array('.png', '.jpg', '.jpeg');
$allowedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_PNG);

$uploaded = new UploadedFile('file');
$error = $uploaded->validateImage($maxBytes, $allowedExtensions, $allowedTypes);
if (is_string($error)) {
    throw new Exception($error);
}

$saveAs = '/webroot/uploads/images/'.basename($uploaded->file->getName());
$saved = $uploaded->saveImage($saveAs, false);
if (empty($saved)) {
    throw new Exception('Sorry, we couldn\'t upload the image.');
}

// do sth with saved image: $saved

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固