承接 eeshiro/file-upload 相关项目开发

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

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

eeshiro/file-upload

Composer 安装命令:

composer require eeshiro/file-upload

包简介

Simple File uploading library capable of handling multiple file uploads

README 文档

README

Simple File uploading library capable of handling multiple file uploads

Installing Add file to Composer.json file:

{
  "require": {
    "eeshiro/file-upload": "~1.0.0"
  }
}

or

composer require eeshiro/file-upload

Usage

require './vendor/autoload.php';

$upload = new FileUpload;
$single_file = $upload->validate('single_file', 'Single File')
				->required()
				->single()
				->max_size(2)
				->get();

$multiple_file= $upload->validate('multiple_file', 'Multiple File')
				->required()
				->multiple()
				->max_size(2, 'MB')
				->max_file(3)
				->get();

if($upload->has_error()){
	echo $upload->get_errors('<br>');
	die();
}

$upload->move_uploaded_file($single_file, 'directory/filename.txt');

foreach ($multiple_file as $key => $file) {
	$upload->move_uploaded_file($file, 'directory/'.$file['name']);
}

Rules and Methods Reference

Rule Parameter Description Example
require No Returns FALSE if the form element is empty.
single No Returns FALSE if file upload type multiple.
multiple No Returns FALSE if file upload type single.
max_file Yes Returns FALSE if file count is greater than maximum number of files specified. max_file(5)
min_file Yes Returns FALSE if file count is less than minimum number of files specified. min_file(2)
image No Returns FALSE if uploaded file is not an image.
exist Yes Returns FALSE if file already exist on the directory. exist(directory)
min_size Yes Returns FALSE file size is under the minimum size specified. Parameter 1 : size (Integer). Parameter 2 : size Type (String) Available size type (KB, MB, GB, TB) min_size(2, 'MB')
max_size Yes Returns FALSE if file exceeds the maximum size specified. Parameter 1 : size (Integer). Parameter 2 : size Type (String) Available size type (KB, MB, GB, TB) min_size(2, 'MB')
valid_format Yes Returns FALSE if file format is not in the list specified. Parameter 1 : file type list (Array) valid_format(['jpg', 'png', 'gif'])
move Yes Moves the validated file to the directory specified. Returns TRUE if successfully saved, FALSE if not. Parameter 1 : directory (String). Parameter 2 : use original filename (Boolean) (true if retain, false if not). move('directory/filename.txt', false)
get No Returns the file validated.
has_error Yes Returns TRUE if validation has error. Parameter 1: file index / file field name (String). NOT REQUIRED.
error_count Yes Returns NUMBER of errors on validation. Parameter 1: file index / file field name (String). NOT REQUIRED.
get_errors Yes Return validation errors. Parameter 1: glue (String) (If NULL returns array of errors). Parameter 1: file index / file field name (String) (NOT required). get_errors('
')
move_uploaded_file Yes Moves the file to the directory specified. Parameter 1 : File from get method (Array). Parameter 2 : File directory. move_uploaded_file($file, 'directory/'.$file['name'])

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固