akhaled / livewire-files
使用 livewire 上传和浏览文件
0.0.1-beta
2020-11-18 00:32 UTC
Requires
- akhaled/livewire-sweetalert: ^0.0.1-beta
- livewire/livewire: ^2.0
This package is auto-updated.
Last update: 2024-09-20 00:30:35 UTC
README
安装
composer require akhaled/livewire-files
需求
需要前端包
如何使用
1. 将 livewire 组件添加到你的视图中
此组件仅在内容中显示一个按钮。此按钮链接到 tailwind 模态框。
@livewire('files-upload', [ 'image' => true, // accept only image, optional 'mimes' => 'pdf,csv', // or specify mime type, optional 'max' => 1024 // max 1024kb by default ])
2. 添加脚本
... @livewireScript <script src="{{ mix('js/app.js') }}"></script> @livewireSweetalertScripts ...
配置
php artisan vendor:publish --tag=livewire-files
将生成全局配置文件。
store_dir
默认为 public (storage/public
)。您需要在 config/filesystems.php 中的 links 属性下添加以下行
public_path('storage') => storage_path('app/public')
验证
image
: 只接受图片,默认 =false
mimes
: 接受的 mimes,默认 =null
(接受所有内容)max
: 最大上传大小,默认 =102400
(以千字节为单位)
计划
- 上传时显示 toast
- 隐藏输入文件并显示javascript链接
- 将内容移动到模态框
- 显示 sweetalert 弹出框而不是静态警报
- 为上传按钮添加按钮文本和按钮颜色
- 指定上传文件的名称
- 将上传移动到年/月/日目录