runthis/laravel-media 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

runthis/laravel-media

Composer 安装命令:

composer require runthis/laravel-media

包简介

Handle media in laravel packages

README 文档

README

A tiny laravel package to conveniently handle single file media uploads with little configuration.

Installation

composer require runthis/laravel-media

Usage

Add to the file you want to process uploads in, such as a controller.

use Runthis\Media\Facades\Media;
use Runthis\Media\Requests\MediaRequest;

Include the MediaRequest class in the function parameter and execute the create method on the Media facade.

Example:

public function upload(MediaRequest $request) {
    $test = Media::create($request);
    dd($test);
}

Inside the dd() you can see the complete object details and process these as you see fit (such as keeping track of these uploads in a database if you like).

Within the object results is a size key. You can simply echo this out to get the bytes, or you can add ->pretty() to get a prettier output. You can also pass a string parameter to the pretty() method.

Options:

l: lowercase suffix (12.45 mb instead of 12.45 MB)
s: spacing omitted (12.45MB instead of 12.45 MB)
b: Ending "B" removed (12.45 M instead of 12.45 MB)

Examples:

$test->size->pretty('sb'); // 12.45M
$test->size->pretty('ls'); // 12.45m
$test->size->pretty('l'); // 12.45 mb
$test->size->pretty('bl'); // 12.45 m

The Media::create method expects a file with the key named file.

Publish Config

If you want, run the below command to add a media.php file to your config folder.

php artisan vendor:publish --tag="media-config"

From the media config file you can change the storage disk name and the rules for the media (such as file types, size limit, etc).

Changelog

Please see CHANGELOG for more information on what has changed recently.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固