program-2/image 问题修复 & 功能扩展

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

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

program-2/image

Composer 安装命令:

composer require program-2/image

包简介

Image is a library for uploading images

README 文档

README

\

Introduction

This minimal PHP library is my attempt to upload images safely by an object oriented approach.

It's 79 lines.

Aims

1- to provide safe uploading.

2- to be fully in an object oriented approach.

3- to have ability to define image name and image extension (to saved with),

also maxSize, imageTypes, errorMassage.

How to use it

Parameters

This is the main method of Image:

save($name, $directory, $file)

$name

  • Is the name that html form assigns to the uploaded image.

$directory

  • Is the destination directory that the image will be saved in.

  • This should be an already existing directory on server.

$file

  • Is the name and extention that you choose for the new uploaded file like personel.png .

  • This third parameter can be omitted from the save() method.

  • If no $file value is provided, the client's uploaded name and extension will be used.

Return value

  • class returns TRUE on success.

  • class returns FALSE on failure.

Image type and size configurations (by State Design Pattern)

  • After instantiating the Image class and before using the save() method you can

allocate values of $maxSize :int (IN BYTES) and $alowedTypes :array (of extensions only),

not feeding them means accepting all sizes and all image types.

errorMessage3

  • Get and directly show the error message any where with using the errorMessage() method of the same object.

  • It returns NULL on a successful image saving.

A Complete Example:


\

$obj = new Image  //-> or any other way like dependency injection

$obj -> maxSize = 4900000;

$obj -> allowedTypes = ['png', 'jpg', 'jpeg']; 

$obj -> save('image','pics/lastfolder','personel.png');

echo ($obj -> errorMessage());


\

Credit

Developed by Ehsan Yousefi mailbox5517@gmail.com [https://fsdeveloper.ir]

Updates

"20/4/2019 first release version 0.0.0"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固