Download the PHP package mainul12501/drag-drop-crop-image-upload without Composer

On this page you can find all versions of the php package mainul12501/drag-drop-crop-image-upload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package drag-drop-crop-image-upload

Drag Drop Crop Image Upload

A Laravel package that provides an elegant drag-and-drop image upload widget with built-in cropping functionality. Perfect for profile pictures, avatars, and any image upload that requires user-controlled cropping.

Latest Version on Packagist License

Features

Requirements

Requirement Version
PHP 8.1 - 8.5
Laravel 11.x, 12.x

Installation

Via Composer (Packagist)

Publish the assets and configuration:

Local Development

Add to your main app's composer.json:

Then run:

Quick Start

1. Render the Widget in Your Blade View

2. Handle the Upload in Your Controller

Usage

Basic Usage

With Custom Options

Inside Bootstrap Modal

Custom Labels

API Reference

DragDropCrop::generateUpload(string $inputName, array $options = [])

Renders the drag-drop-crop widget.

Parameters:

Parameter Type Description
$inputName string Name attribute for the hidden input containing cropped base64 data
$options array Configuration options (see below)

Options:

Option Type Default Description
id string auto-generated Unique widget identifier
file_input_name string {inputName}_file Name for the file input element
aspect_ratio float 1 Width/height ratio (1 = square, 16/9 = widescreen)
crop_width int 300 Output image width in pixels
crop_height int 300 Output image height in pixels
max_size_mb int 5 Maximum allowed file size in MB
quality float 0.8 JPEG compression quality (0.1 - 1.0)
modal_id string null Bootstrap modal ID for auto-reset on close
labels array [] Custom UI text labels

Returns: Illuminate\Support\HtmlString


DragDropCrop::uploadFromBase64(?string $base64String, ?string $directory, ?string $namePrefix, ?string $existingPath)

Converts base64 image data to a file and saves it.

Parameters:

Parameter Type Default Description
$base64String string|null - Base64-encoded image data from the widget
$directory string|null config value Upload directory relative to public/
$namePrefix string|null null Prefix for the generated filename
$existingPath string|null null Path to existing image (will be deleted)

Returns: string|null - Relative path to the uploaded file, or $existingPath if no new upload

Example with all parameters:

Generated filename format: {prefix}_{timestamp}_{random}.{ext}

Example: user_123_1704067200_a1b2c3d4e5.jpg

Configuration

After publishing, edit config/drag-drop-crop.php:

Complete Example

Blade View (create-profile.blade.php)

Controller (ProfileController.php)

Display the Image

Supported Image Formats

Format Extension MIME Type
JPEG .jpg image/jpeg
PNG .png image/png
GIF .gif image/gif
WebP .webp image/webp

User Interaction Flow

  1. User drags an image onto the widget (or clicks to browse)
  2. Selected image appears in the cropping interface
  3. User adjusts the crop area (drag, resize, rotate)
  4. User clicks "Crop Image" to confirm
  5. Cropped preview is shown with option to change
  6. On form submit, base64 data is sent to the server
  7. Server converts base64 to file and returns the path

License

MIT License. See LICENSE for details.

Credits

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links


All versions of drag-drop-crop-image-upload with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mainul12501/drag-drop-crop-image-upload contains the following files

Loading the files please wait ...