PHPackages                             leaderos-net/bulletproof-php7 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. leaderos-net/bulletproof-php7

ActiveLibrary[File &amp; Storage](/categories/file-storage)

leaderos-net/bulletproof-php7
=============================

A simple and secure PHP image uploader

7.4(1y ago)02MITPHPPHP &gt;=7.4

Since Mar 22Pushed 1y agoCompare

[ Source](https://github.com/leaderos-net/bulletproof-php7)[ Packagist](https://packagist.org/packages/leaderos-net/bulletproof-php7)[ Docs](http://github.com/samayo/bulletproof)[ RSS](/packages/leaderos-net-bulletproof-php7/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

BULLETPROOF [![Test](https://github.com/samayo/bulletproof/actions/workflows/php.yml/badge.svg)](https://github.com/samayo/bulletproof/actions/workflows/php.yml)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#bulletproof-)

[![Latest Stable Version](https://camo.githubusercontent.com/7c2397804f9b74c61f185a6df4efa50746ed43d3fde4d97507c208e2bea3e53a/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f762f737461626c652e7376673f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/samayo/bulletproof) [![Total Downloads](https://camo.githubusercontent.com/b21fe68c9c652b7c00be349447a58e4c0ebbdc2e1d9ac5ea66634fe1e58a42c6/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/samayo/bulletproof?format=flat-square) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/96cde15912426553c02d1b76f52799410268ec1a10935e58b2c01bc91a6404ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d61796f2f62756c6c657470726f6f662f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samayo/bulletproof/?branch=master) [![License](https://camo.githubusercontent.com/7b4eec066c6142a6d56b4869a7bbf95fb51e0c49ce08dd629ed235db8d098c76/68747470733a2f2f706f7365722e707567782e6f72672f73616d61796f2f62756c6c657470726f6f662f6c6963656e7365)](https://packagist.org/packages/fastpress/framework)

Bulletproof is a single-class PHP library to upload images securely.

Installation
------------

[](#installation)

Install using git

```
$ git clone https://github.com/samayo/bulletproof.git
```

Install using Composer

```
$ composer require samayo/bulletproof:5.0.*
```

Or [download it manually](https://github.com/samayo/bulletproof/releases) in a ZIP format

Usage
-----

[](#usage)

To quickly upload images, use the following HTML &amp; PHP code:

```

```

```
require_once  "path/to/bulletproof.php";

$image = new Bulletproof\Image($_FILES);

if($image["pictures"]){
  $upload = $image->upload();

  if($upload){
    echo $upload->getPath(); // uploads/cat.gif
  }else{
    echo $image->getError();
  }
}
```

For more options or configurations, check the following examples:

Configs
-------

[](#configs)

#### Setting Properties

[](#setting-properties)

Methods to set restriction on the image name, size, type, etc.. to upload

```
// To provide a name for the image. If unused, image name will be auto-generated.
$image->setName($name);

// To set the min/max image size to upload (in bytes)
$image->setSize($min, $max);

// To define a list of allowed image types to upload
$image->setMime(array('jpeg', 'gif'));

// To set the max image height/width to upload (limit in pixels)
$image->setDimension($width, $height);

// To create a folder name to store the uploaded image, with optional chmod permission
$image->setStorage($folderName, $optionalPermission);
```

#### Getting Properties

[](#getting-properties)

Methods to retrieve image data before/after upload.

```
// To get the image name
$image->getName();

// To get the image size (in bytes)
$image->getSize();

// To get the image mime (extension)
$image->getMime();

// To get the image width in pixels
$image->getWidth();

// To get the image height in pixels
$image->getHeight();

// To get image location (folder where images are uploaded)
$image->getStorage();

// To get the full image path. ex 'images/logo.jpg'
$image->getPath();

// To get the json format value of all the above information
$image->getJson();
```

#### Extended Configuration Usage

[](#extended-configuration-usage)

How to use the property setters and getters.

```
$image = new Bulletproof\Image($_FILES);

$image->setName("samayo")
      ->setMime(["gif"])
      ->setStorage(__DIR__ . "/avatars");

if($image["pictures"]){
  if($image->upload()){
    echo $image->getName(); // samayo
    echo $image->getMime(); // gif
    echo $image->getStorage(); // avatars
    echo $image->getPath(); // avatars/samayo.gif
  }
}
```

#### Image Manipulation

[](#image-manipulation)

To crop, resize or watermak images, use functions stored in [`src/utils`](https://github.com/samayo/bulletproof/tree/master/src/utils)

#### Creating custom errors

[](#creating-custom-errors)

Use php exceptions to define custom error responses

```
if($image['pictures']){
  try {
    if($image->getMime() !== 'png'){
      throw new \Exception('Only PNG image types are allowed');
    }

    // check size, width, height...

    if(!$image->upload()){
      throw new \Exception($image->getError());
    } else {
      echo $image->getPath();
    }

  } catch (\Exception $e){
    echo "Error " . $e->getMessage();
  }
}
```

#### What makes this secure?

[](#what-makes-this-secure)

- Uses **[`exif_imagetype()`](https://php.net/manual/function.exif-imagetype.php)** to get the true image mime (`.extension`)
- Uses **[`getimagesize()`](https://php.net/manual/function.getimagesize.php)** to check if image has a valid height / width in pixels.
- Sanitized images names, strict folder permissions and more...

### License: MIT

[](#license-mit)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

422d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22c3156714cb5ef9745bf9c32b71230fd95b7d21b5815e1e7ad1618c285ff8b1?d=identicon)[benfiratkaya](/maintainers/benfiratkaya)

---

Top Contributors

[![samayo](https://avatars.githubusercontent.com/u/5304093?v=4)](https://github.com/samayo "samayo (182 commits)")[![LorincJuraj](https://avatars.githubusercontent.com/u/18634191?v=4)](https://github.com/LorincJuraj "LorincJuraj (6 commits)")[![fmkoc](https://avatars.githubusercontent.com/u/42084115?v=4)](https://github.com/fmkoc "fmkoc (5 commits)")[![benfiratkaya](https://avatars.githubusercontent.com/u/48600092?v=4)](https://github.com/benfiratkaya "benfiratkaya (3 commits)")[![lordgiotto](https://avatars.githubusercontent.com/u/5115382?v=4)](https://github.com/lordgiotto "lordgiotto (3 commits)")[![effu](https://avatars.githubusercontent.com/u/1723287?v=4)](https://github.com/effu "effu (1 commits)")[![thorsten](https://avatars.githubusercontent.com/u/45284?v=4)](https://github.com/thorsten "thorsten (1 commits)")[![crumpetcrusher](https://avatars.githubusercontent.com/u/5601386?v=4)](https://github.com/crumpetcrusher "crumpetcrusher (1 commits)")[![Mknsri](https://avatars.githubusercontent.com/u/5314500?v=4)](https://github.com/Mknsri "Mknsri (1 commits)")[![progsource](https://avatars.githubusercontent.com/u/1206026?v=4)](https://github.com/progsource "progsource (1 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (1 commits)")[![BitConf](https://avatars.githubusercontent.com/u/9640081?v=4)](https://github.com/BitConf "BitConf (1 commits)")[![tadhgboyle](https://avatars.githubusercontent.com/u/26070412?v=4)](https://github.com/tadhgboyle "tadhgboyle (1 commits)")[![fiil](https://avatars.githubusercontent.com/u/7559777?v=4)](https://github.com/fiil "fiil (1 commits)")

---

Tags

securityimageSimpleupload

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leaderos-net-bulletproof-php7/health.svg)

```
[![Health](https://phpackages.com/badges/leaderos-net-bulletproof-php7/health.svg)](https://phpackages.com/packages/leaderos-net-bulletproof-php7)
```

###  Alternatives

[samayo/bulletproof

A simple and secure PHP image uploader

39853.3k4](/packages/samayo-bulletproof)[presta/image-bundle

PrestaImageBundle is a Symfony bundle providing tools to resize uploaded and remote images before sending them through a classic form.

24155.9k](/packages/presta-image-bundle)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
