PHPackages                             sar-cubet/file-upload - 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. sar-cubet/file-upload

ActiveLibrary

sar-cubet/file-upload
=====================

An interface for users to upload different type of files and store them.

v1.1.8(2y ago)245MITPHP

Since May 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/sar-cubet/file-upload)[ Packagist](https://packagist.org/packages/sar-cubet/file-upload)[ RSS](/packages/sar-cubet-file-upload/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (23)Used By (0)

Laravel File Upload
===================

[](#laravel-file-upload)

[![License](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)

This is a Laravel package that provides file upload functionality with ease. It simplifies the process of handling file uploads in your Laravel application.

Features
--------

[](#features)

- Simple and intuitive file upload handling.
- Integration with Laravel's validation system.
- Image Optimization.
- Image Resize.
- File Storage.
- Chunk File Upload for large files.
- Virus scan.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- Laravel &gt;= 9.52.7

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

[](#installation)

You can install the package via **Composer**. Run the following command:

```
composer require sar-cubet/file-upload

```

Installing the package (publishing the resources)
-------------------------------------------------

[](#installing-the-package-publishing-the-resources)

```
php artisan fileupload:install

```

Implementation
--------------

[](#implementation)

We provide `SarCubet\FileUpload\Facades\Upload` Facade which you can use to perform operations like file validation, image optimization, file storage etc. You can validate your file by using the `Upload::validate()` method. The `Upload::validateFile()` accepts a file of type `Illuminate\Http\UploadedFile` and return a `Illuminate\Support\Facades\Validator` object that you can use as per the application requirement. All the supported file types can be found inside the config file **config/fileupload.php** (which will be published). You can modify the config as per your requirement. Also if you wish to add any other file types, you can add it up inside **allowed\_file\_extensions.others** list in the config file.

```
'allowed_file_extensions' => [
    'image' => ['jpeg', 'jpg', 'png', 'gif'],
    'doc' => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
    'text' => ['txt'],
    'others' => []
]
```

```
use SarCubet\FileUpload\Facades\Upload;

$validator = Upload::validateFile($request->file('file'));
if ($validator->fails()) {
    return response()->json(['status' => 0, 'errors' => $validator->errors()]);
}
```

If you want to use custom validation and/or validation messages you can pass the rules and messages as an associative array (optional)

```
$rules = [
    'required'      => 'The file is required',
    'mimes:jpg,png' => 'The file types should be any of the following: jpg,png',
    'max:5120'      => 'The file size should not exceed 5MB'
];

$validator = Upload::validateFile($request->file('file'), $rules);
```

If you wish to scan the uploaded file for any type of malwares. You can use the `Upload::scanFile()` method(**Note: Its recomented to use before using `validateFile()` or any other services.**). Under the hood we are making use of **ClamAV anti-virus scanner**. So you need to install ClamAV in your machine. Here are the commands for installation (Ubuntu):

```
# Install clamav virus scanner
sudo apt-get update && sudo apt-get install -y clamav-daemon

```

```
# Update virus definitions
sudo freshclam

```

```
# Start the scanner service
sudo systemctl enable --now clamav-daemon clamav-freshclam

```

Additionally you can use `isFileInfected()` and `getMalwareName()` methods identify and provide information of any malware like below:

```
$scan_file = Upload::scanFile($request->file('file'));

if ($scan_file->isFileInfected()) {
    return "This file is found with the malware :" . $scan_file->getMalwareName() . '.';
} else {
    return "This file is safe to upload.";
}
```

You can optimize the image by using `Upload::optimizeImage()` method. Optimization is provided in 3 levels **(excellent, moderate and average)**.

```
$file = Upload::optimizeImage($request->file('image'), 'moderate');
```

You can resize the image by using `Upload::resize()` method. The `resize()` method accepts 4 parameters: **width, height, file and preserve\_aspect\_ratio (optional)**

```
Upload::resize(200, null, $file);
```

or

```
Upload::resize(200, null, $file, true);
```

File storage is possible through `Upload::store()` method. `store()` accepts 3 parameters: **file, disk\_name, path (optional)**

```
$url = Upload::store($file, 's3');
```

or

```
$url = Upload::store($file, 's3', 'your_path');
```

Chunk file upload functionlaity is provided. You can use `Upload::receiveChunks()` method to receive chunks and its metadata. You can pass the `$request` instance into the method. The function will automatically recieve the metadata and each chunks and combine the chunks into a new file when all chunks are received.

```
use Illuminate\Http\Request;

public function chunkFileUpload(Request $request)
{
    $recieve = Upload::receiveChunks($request);
}
```

The first Http POST request should contain the metadata and then the chunks should be send. The metadata should contain the data as shown below.

```
metadata:{
    chunk_size: chunk_size,
    total_chunk_count: total_chunk_count,
    file_size: file_size,
    file_extension: file_extension
}
```

You can check upload status and store the file like below.

```
if($receive->isUploadComplete()){
    Upload::store($receive->getFile(), 'public');
}
```

We also provide two methods for getting the last uploaded chunk and upload progress in percentage.

```
$receive->getLastUploadedChunkIndex();
$receive->getUploadProgressInPercentage();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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

Every ~1 days

Total

19

Last Release

1069d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42c47ff262bc0588f66970f514795594fada947a0df91c68035966b483c4b1ae?d=identicon)[sar-cubet](/maintainers/sar-cubet)

---

Top Contributors

[![sar-cubet](https://avatars.githubusercontent.com/u/133192615?v=4)](https://github.com/sar-cubet "sar-cubet (21 commits)")[![nandul-cubettech](https://avatars.githubusercontent.com/u/77288998?v=4)](https://github.com/nandul-cubettech "nandul-cubettech (14 commits)")

### Embed Badge

![Health badge](/badges/sar-cubet-file-upload/health.svg)

```
[![Health](https://phpackages.com/badges/sar-cubet-file-upload/health.svg)](https://phpackages.com/packages/sar-cubet-file-upload)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[laravolt/avatar

Turn name, email, and any other string into initial-based avatar or gravatar.

2.0k5.4M31](/packages/laravolt-avatar)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M73](/packages/unisharp-laravel-filemanager)[aimeos/aimeos-core

Full-featured e-commerce components for high performance online shops

4.5k346.9k48](/packages/aimeos-aimeos-core)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M100](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k22](/packages/bkwld-croppa)

PHPackages © 2026

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