vadiasov/upload
Composer 安装命令:
composer require vadiasov/upload
包简介
Laravel package to multi upload files with 'drug and drop' using dropzone.js
README 文档
README
PHP configuration
PHP must be able to upload your files. That means that upload_max_filesize and post_max_size must be equal to appropriate value.
For example:
Find php.ini. Insert in the working file:
<?php
phpinfo();
Open this file in any browser. See where is your php.ini. Open it in terminal. For example (Ubuntu 16.04):
sudo nano /etc/php/7.0/fpm/php.ini
Find upload_max_filesize and post_max_size and change their values. For example:
post_max_size=128M
upload_max_filesize=128M
Then you need to restart PHP. For example:
service php7.0-fpm restart
After that check phpinfo() again to be sure that PHP got new values.
Preparation
You need to have a directory to upload files. Decide first where do you want to place uploaded files. As rule it's some subdirectory in storage/app/public.
When you have decided about subdirectory:
- write it in a config (see next section)
- create it in a real file system
- get appropriate access (777) to it.
Installation
- Create row in the application root composer:
"require": {
...
"vadiasov/upload": "^1.0",
...
},
2.Run in your terminal:
cd your_application_root
composer update
3.This package is developed with discovery feature. So it must itself to create row in a config/app.com about ServiceProvider:
/*
* Package Service Providers...
*/
...
Vadiasov\Upload\UploadServiceProvider::class,
4.Publish Assets. dropzone.js and dropzone.css will be copied from the package to public/js and css directories accordingly. 5.Edit config file that you will use in outer controller to start upload (for example: config/upload-admin.php): 5.1.For a single parent:
return [
'rules' => [
'url' => '/arts-store',
'acceptedFiles' => 'image/*',
'maxFilesize' => '250000',
],
'path' => '/app/public/arts/',
'db_table' => 'arts',
'id_item' => 'album_id',
'id_item_2' => '',
'column' => 'file',
'backUrl' => '\Vadiasov\ArtsAdmin\Controllers\ArtsController@index',
'pageHeader' => 'Arts',
'header' => 'Add arts to the album ',
'parent_table' => 'albums',
'parent_column_name' => 'title',
'view' => 'upload_3',
];
5.1.For a two-parents case:
return [
'rules' => [
'url' => '/items-store',
'acceptedFiles' => 'image/*',
'maxFilesize' => '250000',
],
'path' => '/app/public/arts/',
'db_table' => 'arts',
'id_item' => 'album_id',
'id_item_2' => 'track_id',
'column' => 'file',
'backUrl' => '\Vadiasov\ArtsAdmin\Controllers\ArtsController@indexTrack',
'pageHeader' => 'Arts',
'header' => 'Add arts to the track ',
'header_second_part' => ' of the album ',
'parent_db_table' => 'albums',
'sub_parent_db_table' => 'tracks',
'parent_column_name' => 'title',
'sub_parent_column_name' => 'title',
'view' => 'upload_4',
];
- where url - package route of package controller function that process files
- acceptedFiles - mime rules for uploading files
- maxFilesize - maximum file size that is accepted
- path - path to directory of uploaded files
- db_table - DB table name where you save file names of uploaded files
- column - table column name that keep file names of uploaded files
- id_item - table column name that you can use to bind uploaded file to. For example, "album_id" of album that has this file (track).
- backUrl - route name for a button "Back" under the form of uploading (you uploaded all files and click it to come back to somewhere).
- header - String that may be inserted in the Upload form header (with title of an album).
- parent_table - DB table name of parent packages. For example may be used to get a title of album.
- parent_column_name - DB table column name of parent packages. For example may be used to get a title of album.
Using
Open page with route for a single parent:
'/tracks-upload/{config}/{id}'
Open page with route for a two-parents case:
'/tracks-upload/{config}/{first_parent_id}/{second_parent_id}'
to open upload form. Where
- config - name of config file (see p.4 - upload-admin)
- id - parameter that you can use (for examle: id of album that has to include uploading tracks).
Example:
- first parent - Album
- second parent - tracks we upload arts for a specific track of an album.
vadiasov/upload 适用场景与选型建议
vadiasov/upload 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vadiasov/upload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vadiasov/upload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-03