承接 siriusphp/upload 相关项目开发

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

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

siriusphp/upload

最新稳定版本:4.0.0

Composer 安装命令:

composer require siriusphp/upload

包简介

Framework agnostic upload library

README 文档

README

Source Code Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Framework agnostic upload handler library.

Features

  1. Validates files against usual rules: extension, file size, image size (wdith, height, ratio). It uses Sirius Validation for this purpose.
  2. Moves valid uploaded files into containers. Containers are usually local folders but you can implement your own or use other filesystem abstractions like Gaufrette or Flysystem.
  3. Works with PSR7 UploadedFileInterface objects and with Symfony's UploadedFiles (see integrations).

Used by Bolt CMS

Elevator pitch

use Sirius\Upload\Handler as UploadHandler;
$uploadHandler = new UploadHandler('/path/to/local_folder');

// validation rules
$uploadHandler->addRule('extension', ['allowed' => ['jpg', 'jpeg', 'png']], '{label} should be a valid image (jpg, jpeg, png)', 'Profile picture');
$uploadHandler->addRule('size', ['max' => '20M'], '{label} should have less than {max}', 'Profile picture');

$result = $uploadHandler->process($_FILES['picture']); // ex: subdirectory/my_headshot.png

if ($result->isValid()) {
	// do something with the image like attaching it to a model etc
	try {
		$profile->picture = $result->name;
		$profile->save();
		$result->confirm(); // this will remove the .lock file
	} catch (\Exception $e) {
		// something wrong happened, we don't need the uploaded files anymore
		$result->clear();
		throw $e;
	}
} else {
	// image was not moved to the container, where are error messages
	$messages = $result->getMessages();
}

Links

统计信息

  • 总下载量: 562.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 228
  • 点击次数: 1
  • 依赖项目数: 13
  • 推荐数: 0

GitHub 信息

  • Stars: 223
  • Watchers: 12
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-23