Download the PHP package mohamedsamy902/advanced-file-upload without Composer

On this page you can find all versions of the php package mohamedsamy902/advanced-file-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 advanced-file-upload

Laravel Media Vault

A highly scalable, production-ready file and media management package for Laravel. It provides unified management for centralized uploads and custom polymorphic model fields, seamlessly handling URL downloads, image processing, massive datasets with robust memory safety, and chunked resumable uploads.

Latest Version on Packagist PHP Version Require Laravel Version Require [Tests]()

Table of Contents

  1. Features
  2. Requirements
  3. Installation
  4. Configuration
  5. Usage Examples
  6. Response Format
  7. Database Model
  8. Dashboard & Media Manager UI
  9. Cloud Storage Setup
  10. Console Commands
  11. ⚠️ Danger Zone / Known Limitations
  12. Testing
  13. Advanced Security & Performance Features
  14. Security
  15. Contributing
  16. Changelog
  17. License

1. Features


2. Requirements

Requirement Version Notes
PHP ^8.2
Laravel >=10.0
Extensions ext-gd or ext-imagick Required for image processing

3. Installation

1. Install via Composer:

2. Publish Configuration:

3. Run Migrations (Optional, requires database.enabled = true):


4. Configuration

This package is highly customizable through config/media-vault.php. Below is a comprehensive list of every configuration key available.

Storage (storage)

Key Type Default Description
storage.disk string 'public' The default Laravel storage disk to use.
storage.path string 'uploads' The base directory inside the selected disk.
storage.default_folder string 'default' The default subfolder used if none is specified during upload.
storage.cdn.enabled boolean false Whether to replace the storage URL domain with a CDN domain.
storage.cdn.url string '' The base URL of your CDN.

Validation (validation)

Contains standard Laravel validation strings mapped to file types (image, video, audio, document, other, custom_fields). Used internally to validate incoming files based on rules like sizes and MIME types.

URL Upload / Download (url_download & url_upload)

Key Type Default Description
url_download.enabled boolean true Allow uploading files via a remote URL.
url_download.chunked boolean true True = load into memory; False = stream to disk directly.
url_download.chunk_size int 5242880 Size of streaming chunks (5MB).
url_download.allowed_mimes array [...] Whitelisted extensions for URL downloads grouped by type.
url_upload.allowed_domains array [] Allowed domains for SSRF protection (empty = allow all public).
url_upload.timeout_seconds int 10 Hard timeout for the download HTTP request (overrides legacy url_download.timeout).
url_upload.max_size_bytes int 52428800 Max file size allowed from a URL (50MB default) (overrides legacy url_download.max_size).

Image Processing (image_driver & processing)

Key Type Default Description
image_driver string 'gd' 'gd' or 'imagick' (Requires corresponding PHP extension).
processing.image.enabled boolean true Enable/disable all image processing features.
processing.image.resize array [...] Contains width, height, maintain_aspect_ratio, and upsize.
processing.image.watermark array [...] Contains enabled, path, position, opacity, x_offset, y_offset.
processing.image.filters array [] Allowed filters: brightness, contrast, greyscale, blur.
processing.image.convert_to string|null 'webp' Global format conversion target (e.g. webp, jpg).
processing.image.quality int 85 Compression quality (1-100).
processing.image.optimize boolean false Optional integration for Spatie image optimizer.
processing.video.enabled boolean false Enable video processing features.
processing.video.convert_to string 'mp4' Target video format.
processing.video.bitrate string '1000k' Target video bitrate.
processing.video.resolution string '1280x720' Target video resolution.

Thumbnails (thumbnails)

Key Type Default Description
thumbnails.enabled boolean true Automatically generate thumbnails during image upload.
thumbnails.sizes array [...] Associative array of sizes (e.g. small => ['width' => 150, 'crop' => true]).
thumbnails.for_videos boolean false Generate thumbnails for video files (requires FFmpeg).
thumbnails.seconds int 5 Second to capture for video thumbnails.

Quota Management (quota)

Key Type Default Description
quota.enabled boolean false Enable storage quotas per user.
quota.max_size_per_user int 1073741824 1 GB default max size.
quota.key_column string 'user_id' DB column to identify owner. Change to tenant_id for multi-tenant.
quota.warning_threshold float 0.9 Fraction (e.g. 0.9 = 90%) to trigger QuotaWarning event.
quota.check_method string 'database' Method for checking quota (database or session).

Multi-Source & DB Tracking (media_models, database)

Key Type Default Description
media_models array [] List of Custom Eloquent models using HasMediaFields.
max_orphan_scan_limit int 100000 Cap on files scanned per run to prevent memory exhaustion.
database.enabled boolean true Track uploads in the file_uploads table.
database.model string FileUpload::class Class reference for the database model.
database.table string 'file_uploads' Database table name.
database.prune_after int|null 30 Days to retain soft-deleted/unused records before physical prune.

Security & Chunks (security, chunked)

Key Type Default Description
security.bulk_delete_warning_threshold int 100 Deletions exceeding this require an extra warning.
security.strict_mime_validation boolean true Validate file binary magic bytes against declared MIME type.
security.rate_limit.enabled boolean false Enable upload rate limiting.
security.rate_limit.max_uploads int 60 Max uploads per time window.
security.rate_limit.per_minutes int 1 Time window in minutes.
security.virus_scan.enabled boolean false Enable ClamAV virus scanning.
security.virus_scan.driver string 'clamav' Virus scanning driver.
security.virus_scan.path string '/usr/bin/clamscan' Path to the ClamAV executable.
chunked.session_ttl_hours int 24 Hours to keep pending resumable upload sessions before expiration.

Advanced Features (temp_url, compression, logging)

Key Type Default Description
temp_url.route_prefix string 'media-vault-urls' Prefix for temporary signed URL routes.
temp_url.middleware array [] Middleware for temporary signed URLs.
compression.enabled boolean false Enable file compression (e.g., zip) before storage.
compression.types array [...] File extensions eligible for compression.
compression.quality int 80 Compression quality level.
logging.enabled boolean true Enable internal operation logging.
logging.level string 'info' The log level to use.

UI Dashboard (ui)

Key Type Default Description
ui.route_prefix string 'media-vault' Base URL for the Media Manager Dashboard.
ui.middleware array ['web'] CRITICAL: Add 'auth' to protect the dashboard!

5. Usage Examples

Single & Multiple File Upload via HTTP Request

Direct Upload with UploadedFile

Upload from Remote URL

Upload Methods & Integration Scenarios

The package supports three distinct integration approaches depending on your application frontend architecture:

Option A: Traditional Blade HTML Form (No JS / Non-Chunked)

For standard Laravel applications submitting traditional HTML forms directly to the backend:

Blade Template (resources/views/upload.blade.php):

Laravel Controller:


Option B: Resumable Chunked Uploads (Blade + JS Client)

For web applications requiring client-side progress bars and auto-resumption across page refreshes or network drops:

Blade Template (resources/views/resumable-upload.blade.php):

Frontend JS Client Capabilities (media-vault.js)

Option C: Mobile Applications & REST APIs (Flutter, React Native, Swift, Kotlin)

For mobile applications or single-page applications (SPAs) connecting via REST endpoints:

1. Send Chunks Sequentially

Upload binary chunk data to POST /media-vault/upload (or your custom API endpoint):

Response (First Chunk):

Mobile App stores sessionId in local storage (SharedPreferences / AsyncStorage / Hive).

2. Query Session Ground Truth on Re-Open / Resume

If the mobile app crashes or network disconnects, query the session status to get the exact missing chunk indices:

Response:

3. Send Missing Chunks & Complete Assembly

The mobile app sends only the indices listed in missing_chunks along with the sessionId. When the final chunk arrives, the server returns the completed UploadResult JSON object.

Using Central DB Tracking (HasUploads)

Use the HasUploads trait to link files to your models polymorphically via the file_uploads table.

Multi-Source Media Setup (HasMediaFields)

Use the HasMediaFields trait on models where you want to store file paths directly in the model's table columns, bypassing the central file_uploads table tracking while retaining the package UI, URL resolution, and scanners.

Run php artisan media-vault:discover-models to auto-register this model in your configuration cache.

Generating Thumbnails & Watermarks

Thumbnails and watermarks are generated automatically based on config/media-vault.php.

Warning: Watermarking is a destructive operation. It overrides the original image.

Deleting Files

Bulk Deletion Guard

Available in the BulkDeletionGuard utility service. Always preview a massive deletion action and generate a secure token to proceed.


6. Response Format

All successful uploads return an UploadResult object. It seamlessly implements ArrayAccess and JsonSerializable.

Failed items in a batch upload will return an array:


7. Database Model

If database.enabled is true, all uploads go to the file_uploads table. The FileUpload model includes powerful query scopes:


8. Dashboard & Media Manager UI

The package provides a built-in Single Page Application (SPA) dashboard to manage files, view sessions, configure settings, and scan for orphaned files.


9. Cloud Storage Setup

To use Amazon S3 or Google Cloud Storage, you must require their Flysystem adapters. The package will intelligently throw a clear exception if they are missing.


10. Console Commands

The package registers several utilities to simplify file management:


11. ⚠️ Danger Zone / Known Limitations

[!CAUTION] Pay strict attention to these operational warnings to prevent data loss in a production environment:

  1. Thumbnails Backfill Limitation: The command media-vault:regenerate-thumbnails works flawlessly for the central file_uploads repository. However, it does NOT support Custom Models (Multi-Source) currently. Enabling thumbnails.enabled retroactively will not backfill thumbnails for custom models.
  2. Watermarks are Destructive: Enabling watermark.enabled prints the watermark directly onto the original image. There is no backfill, and there is no way to remove a watermark once applied.
  3. Removing Custom Models = Data Loss Risk: If you remove a model from media_models in the config after files have been uploaded, the scanner will immediately classify its files as "Orphaned". Running the Orphan Deletion will permanently wipe them. Always migrate or empty tables before changing configuration topology.
  4. Custom Sources Pagination: To prevent Server Crashes (OOM) on huge DB tables, the Dashboard pagination for Custom Sources operates on Database Rows, not individual files. A JSON array of 5 images counts as 1 row in pagination.
  5. Caching: If you register a new model or trait, you must run php artisan config:clear so the Dashboard recognizes it.

12. Testing

The package includes a comprehensive test suite. We specifically isolate heavy tests (Benchmarks) to prevent CI timeouts.

Run Unit & Feature Tests:

Run Memory & Performance Benchmarks:

(Current Test Count: 177 Passing/Skipped Tests).


13. Advanced Security & Performance Features

🛡️ Virus Scanning (ClamAV Integration)

The package includes built-in automated virus and malware scanning via ClamAV before any file is saved to storage.

⚡ File & Image Compression

Pipeline-integrated file compression reduces storage footprint for non-image document formats.

⏱️ Dual-Layer Rate Limiting

The package distinguishes between two distinct rate limiting safeguards:

  1. Package API Route Limiting (throttle:media-vault-api): Protects your application's endpoints (POST /media-vault/upload, POST /media/bulk-destroy, etc.) from abuse and denial-of-service attacks.

    When exceeded, endpoints return HTTP 429 Too Many Requests with { "status": false, "message": "Too Many Requests. Rate limit exceeded for file operations." }.

  2. External Remote URL Throttling (UrlDownloader): Handles HTTP 429 status responses gracefully when downloading assets from remote third-party CDNs during URL uploads, failing fast with informative error messages.

14. Security

If you discover any security-related issues (such as bypasses for SSRF, traversal attacks, or token leaks in the Bulk Deletion Guard), please email [email protected] directly instead of opening a public issue. Alternatively, you can use GitHub Security Advisories if enabled on the repository.


15. Contributing

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Ensure all tests pass (composer test).
  5. Push to the branch (git push origin feature/amazing-feature).
  6. Open a Pull Request.

16. Changelog

Please see the CHANGELOG.md for more information on what has changed recently.


17. License

The MIT License (MIT). Please see License File for more information.


All versions of advanced-file-upload with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version >=10.0
intervention/image Version ^3.0
enshrined/svg-sanitize Version ^0.22.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 mohamedsamy902/advanced-file-upload contains the following files

Loading the files please wait ...