samayo / Bulletproof
Licence: mit
PHP secure Image uploader, with a nice API
Stars: ✭ 352
Projects that are alternatives of or similar to Bulletproof
Upload Image To Smms By Automator
Drag your image to me, I will upload it to SM.MS automatically and backup info to iCloud. 只需拖拽图片即可轻松上传至 SM.MS 图床并且复制链接,所有图片和链接信息会被备份至 iCloud 方便后期检索。
Stars: ✭ 15 (-95.74%)
Mutual labels: image, upload
Laravel Imageupload
Upload image using Laravel's build in function and resize it automatically.
Stars: ✭ 73 (-79.26%)
Mutual labels: image, upload
Flickrsync
A command line tool to synchronise, upload, download, pictures between the local file system and Flickr. Image hash signature of the picture is used to uniquely identify the image.
Stars: ✭ 14 (-96.02%)
Mutual labels: image, upload
Laravel Imageup
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image
Stars: ✭ 646 (+83.52%)
Mutual labels: image, upload
Uploadcare Widget
Uploadcare Widget, an ultimate tool for HTML5 file upload supporting multiple file upload, drag&drop, validation by file size/file extension/MIME file type, progress bar for file uploads, image preview.
Stars: ✭ 183 (-48.01%)
Mutual labels: image, upload
React Images Uploading
The simple images uploader applied Render Props pattern that allows you to fully control UI component and behaviors.
Stars: ✭ 80 (-77.27%)
Mutual labels: image, upload
Miniflix
Miniflix - A smaller version of Netflix powered by Cloudinary
Stars: ✭ 58 (-83.52%)
Mutual labels: image, upload
Sjnetwork
SJNetwork is a high level network request tool based on AFNetworking and inspired on YTKNetwork.
Stars: ✭ 231 (-34.37%)
Mutual labels: image, upload
React Files
A file input (dropzone) management component for React
Stars: ✭ 126 (-64.2%)
Mutual labels: image, upload
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-73.86%)
Mutual labels: image, upload
Antd Img Crop
🔪 An image cropper for Ant Design Upload
Stars: ✭ 207 (-41.19%)
Mutual labels: image, upload
File Upload With Preview
🖼 A simple file-upload utility that shows a preview of the uploaded image. Written in pure JavaScript. No dependencies. Works well with Bootstrap 4 or without a framework.
Stars: ✭ 352 (+0%)
Mutual labels: image, upload
Maplebacon
🍁🥓 Lightweight and fast Swift library for image downloading, caching and transformations
Stars: ✭ 322 (-8.52%)
Mutual labels: image
Assetspickerviewcontroller
Powerfully Customizable - Multiple Photo & Video Picker Controller
Stars: ✭ 321 (-8.81%)
Mutual labels: image
Guillotine
jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate.
Stars: ✭ 318 (-9.66%)
Mutual labels: image
Frescoutils
Fresco 的封装,快速上手,图像后处理,超大图高清预览,缩小放大,双击放大等一一俱全。简书 http://www.jianshu.com/p/cd058a924288
Stars: ✭ 345 (-1.99%)
Mutual labels: image
Phpmussel
PHP-based anti-virus anti-trojan anti-malware solution.
Stars: ✭ 337 (-4.26%)
Mutual labels: upload
Gh Action Pypi Publish
GitHub Action, for publishing distribution files to PyPI
Stars: ✭ 317 (-9.94%)
Mutual labels: upload
BULLETPROOF
Bulletproof is a single-class library to upload images in PHP with security.
Install
Using git
$ git clone https://github.com/samayo/bulletproof.git
Or composer
$ composer require samayo/bulletproof:4.0.*
Or download it manually based on the archived version of release-cycles.
Usage
Create an HTML form like this.
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000"/>
<input type="file" name="pictures" accept="image/*"/>
<input type="submit" value="upload"/>
</form>
And copy & paste the following code to upload the image
require_once "path/to/bulletproof.php";
$image = new Bulletproof\Image($_FILES);
if($image["pictures"]){
$upload = $image->upload();
if($upload){
echo $upload->getFullPath(); // uploads/cat.gif
}else{
echo $image->getError();
}
}
For more flexibility, check the options and examples below.
Configs
Setting Properties
Before uploading, you can use these methods to restrict the image size, dimensions, mime types, location...
// Pass a custom name, or it will be auto-generated
$image->setName($name);
// define the min/max image upload size (size in bytes)
$image->setSize($min, $max);
// define allowed mime types to upload
$image->setMime(array('jpeg', 'gif'));
// set the max width/height limit of images to upload (limit in pixels)
$image->setDimension($width, $height);
// pass name (and optional chmod) to create folder for storage
$image->setLocation($folderName, $optionalPermission);
Getting Properties
Methods for getting image info before/after upload.
// get the provided or auto-generated image name
$image->getName();
// get the image size (in bytes)
$image->getSize();
// get the image mime (extension)
$image->getMime();
// get the image width in pixels
$image->getWidth();
// get the image height in pixels
$image->getHeight();
// get image location (folder where images are uploaded)
$image->getLocation();
// get the full image path. ex 'images/logo.jpg'
$image->getFullPath();
// get the json format value of all the above information
$image->getJson();
Customized example
This will set image constrains and return output after upload
$image = new Bulletproof\Image($_FILES);
$image->setName("samayo")
->setMime(["gif"])
->setLocation(__DIR__ . "/avatars");
if($image["pictures"]){
if($image->upload()){
echo $image->getName(); // samayo
echo $image->getMime(); // gif
echo $image->getLocation(); // avatars
echo $image->getFullPath(); // avatars/samayo.gif
}
}
Image Manipulation
To crop, resize or watermak images, use functions stored in src/utils
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->getFullPath();
}
} catch (\Exception $e){
echo "Error " . $e->getMessage();
}
}
What makes this secure?
- Uses
exif_imagetype()
to get the true image mime (.extension
) - Uses
getimagesize()
to check if image has a valid height / width in pixels. - Sanitized images names, strict folder permissions and more...
License: MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].