codad5/file-helper 问题修复 & 功能扩展

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

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

codad5/file-helper

Composer 安装命令:

composer require codad5/file-helper

包简介

FIle Uploader is a php package to aid fast , easy and safe file upload

README 文档

README

FIle Uploader is a php package to aid fast , easy and safe file upload

installation

composer require codad5/file-helper

Features

  • Fast and easy to use with method chaining
  • Good error management
  • Safety management
  • works for both multiple file upload and single file upload

Usage

index.php

<form action="./upload.php" method='post' enctype="multipart/form-data">
    <input type="file" name="test[]" multiple>
    <input value="submit" type="submit">
</form>

upload.php

<?php
    include(__DIR__ . '/../vendor/autoload.php');
    
    $file_upload_controller = new Codad5\FileHelper\FileUploader('test', "uploads/");

test - the name given to the $_FILES array by default - for refrence $_FILES['test]`

uploads/ - Upload path relative to upload.php

To add allowed extension

#any other extension aid the given will give error or ignored depending on your error settings
$file_upload_controller->add_ext('svg', 'png');

To set File Prefix

# for unique id can be replaced with uniqid('', true)
$file_upload_controller->set_prefix('my prefix');

To set max and min size

$file_upload_controller->set_sizes(10000, 20);

10000 - This is the maximum file size allowed, to ignore for your .ini config set it to null 20 - This is the minimum file size allowed default equals 0

Turing on/Off Error reporting

/**
 * This is use to turn on and off reporting of the upload process
 * @param bool $file_error - to report error imbound in file from request if `true` else ignore
 * @param bool $size_error - TO report size related error if `true` else ignore
 * @param bool $type_error - To report error related to file type if `true` else ignore
 */
$file_upload_controller->set_reporting(true, false, true);
  • The first param $file_error is to report error imbounded in file from request as found in $_SERVER['test']
  • The second param $size_error is to report size related error depending on your settings
  • The Third param $type_error is to report error if a file is not part of the allowed file

NOTE: If any is false and error is found it will ignore the file and continue upload with out the file

Moving the file

$file_upload_controller->move_files();

Get Uploaded file path

$upload_path = $file_upload_controller->get_uploads();

foreach ($upload_path as $key => $value) {
        # code...
        echo "This file has been uploaded to ".$value['uploaded_path']."<br/>;
    }
  • This returns a multi-dimensional array of each array with the following key
  • uploaded_path - The final uploaded file with path relative to the script tag upload.php
  • name - The name of the file
  • size - The size of the file
  • type - The file Type
  • ext - The file extension

Method Chaining

$file_upload_controller = new \Codad5\FileHelper\FileUploader('tes', "uploads/");

    $uploaded_file_array = $file_upload_controller
    ->set_reporting(false, false, false)
    ->add_ext('png', 'pdf')
    ->set_prefix('cool Stuff')
    ->move_files()
    ->get_uploads();

    foreach ($uploaded_file_array as $key => $value) {
        # code...
        echo "This file has been uploaded to ".$value['uploaded_path']."<br/>";
    }

This documentaion will be updated in time as the project grows for enquire and more information contact me here

Built with 💗 by Chibueze Michael A.

codad5/file-helper 适用场景与选型建议

codad5/file-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 codad5/file-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codad5/file-helper 我们能提供哪些服务?
定制开发 / 二次开发

基于 codad5/file-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-07