pa-bru/file-uploader 问题修复 & 功能扩展

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

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

pa-bru/file-uploader

Composer 安装命令:

composer require pa-bru/file-uploader

包简介

File uploader for PHP

README 文档

README

Presentation

FileUploader is a php class which enables you to upload files on your website !

features :

  • Upload various type of files. You can choose the allowed formats.
  • Rename uploaded files
  • Choose location of the uploaded files
  • Image resizing

Installation

FileUploader is available via Composer/Packagist, so just add this line to your composer.json file:

"pa-bru/file-uploader": "~1.0"

or

composer require pa-bru/file-uploader

Usage

Call the class:

$file = $_FILES["myfile"];

$args = [
	  "fileName" => "my-filename",
          "contentDir" => "my-directory/",
          "allowedExts" => array(),
          "maxSize" => 1000000,
          "width" => 200,
          "height" => 300
];

$uploader = new FileUploader($file, $args);

$file : File upload data table $file is required

$args : table arguments that can be passed to the constructor $args is optional. eg: $uploader = new FileUploader($file);

Properties

  • fileName : name of file. If not specified, a single string is assigned.
  • contentDir : Destination folder of the file added. The folder is created if it does not exist.
  • allowedExts : Table of allowed extensions.
  • maxSize : The maximum file size in bytes.
  • width : In pixel (px) for resizing images (PNG, JPEG, JPG, GIF).
  • height : In pixel (px) for resizing images (PNG, JPEG, JPG, GIF).

Get the parameters (Getters) :

  • Get file extension :
$uploader->getFileExtension();
  • Get the destination path of the file :
$uploader->getPath();
  • Get the height to be assigned to the image file :
$uploader->getHeight();
  • Get the width to be assigned to the image file :
$uploader->getWidth();
  • Get the maximum file size :
$uploader->getMaxSize();
  • Get the destination folder of the file :
$uploader->getContentDir();
  • Get the filename :
$uploader->getFileName();
  • Get file data table :
$uploader->getTmpFile();
  • Get the allowed extensions for uploading a file :
$uploader->getAllowedExts();

Set the parameters (Setters) :

  • Set file path :
$uploader->setPath($path);
  • Set the height to be assigned to the file (if it is an image) :
$uploader->setHeight($height);
  • Set the width to be assigned to the file (if it is an image):
$uploader->setWidth($width);
  • Set the maximum size allowed for file upload :
$uploader->setMaxSize($maxSize);
  • Set the destination folder of the file :
$uploader->setContentDir($contentDir);
  • Set the name to be assigned to the file :
$uploader->setFileName($fileName);
  • Set the file to upload :
$uploader->setTmpFile($tmpFile);
  • Set the table of allowed extensions for file upload :
$uploader->setAllowedExts(array $allowedExts);

Launch upload :

$uploader->upload();

If successful the upload () method returns the path of the uploaded file.

Releases

v1.0 :

  • Initial Version

Author

Copyright © 2016 Paul-Adrien Bru | MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固