PHPackages                             ikechukwukalu/clamavfileupload - 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. ikechukwukalu/clamavfileupload

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

ikechukwukalu/clamavfileupload
==============================

File upload with ClamAV anti-virus scan

v3.0.1(2y ago)57.5k1[1 PRs](https://github.com/ikechukwukalu/clamavfileupload/pulls)1MITPHPPHP &gt;=8.0CI failing

Since Feb 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ikechukwukalu/clamavfileupload)[ Packagist](https://packagist.org/packages/ikechukwukalu/clamavfileupload)[ RSS](/packages/ikechukwukalu-clamavfileupload/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (12)Versions (19)Used By (1)

CLAMAV FILE UPLOAD
==================

[](#clamav-file-upload)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cdeb58cd552d17351c54e87a07f245377c98e80ee84d2c233bfe3a98f4685bc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696b656368756b77756b616c752f636c616d617666696c6575706c6f61643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ikechukwukalu/clamavfileupload)[![Quality Score](https://camo.githubusercontent.com/ed24fe8f59ea5336cd3108ca3b1d49770788bcb3461e4bd50cd8a49198f3d9e0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f696b656368756b77756b616c752f636c616d617666696c6575706c6f61642f6d61696e3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ikechukwukalu/clamavfileupload/)[![Code Quality](https://camo.githubusercontent.com/27b2f92a44de4728201f6ab5a6611dec8464abdb536593176e6a96e5ed0fe097/68747470733a2f2f696d672e736869656c64732e696f2f636f6465666163746f722f67726164652f6769746875622f696b656368756b77756b616c752f636c616d617666696c6575706c6f61643f7374796c653d666c61742d737175617265)](https://www.codefactor.io/repository/github/ikechukwukalu/clamavfileupload)[![Known Vulnerabilities](https://camo.githubusercontent.com/b5172de5cff0e37fe3afe359470a4d5099fc9c94fba95193aad5003ad7ea3872/68747470733a2f2f736e796b2e696f2f746573742f6769746875622f696b656368756b77756b616c752f636c616d617666696c6575706c6f61642f62616467652e7376673f7374796c653d666c61742d737175617265)](https://security.snyk.io/package/composer/ikechukwukalu%2Fclamavfileupload)[![Github Workflow Status](https://camo.githubusercontent.com/3c5555844e45b5ce3ba9d3224635b22c6e9fe321e78b6790f2e5bafd84e21645/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696b656368756b77756b616c752f636c616d617666696c6575706c6f61642f636c616d617666696c6575706c6f61642e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/ikechukwukalu/clamavfileupload/actions/workflows/clamavfileupload.yml)[![Total Downloads](https://camo.githubusercontent.com/e46aaebd027f96fb61bc831eb9124b3818c609dea54d01078b4a71f6727a715b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696b656368756b77756b616c752f636c616d617666696c6575706c6f61643f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ikechukwukalu/clamavfileupload)[![Licence](https://camo.githubusercontent.com/77a615870c9b3d575987b24a96b71bc2bd48e9239612dcea420884d99e182252/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696b656368756b77756b616c752f636c616d617666696c6575706c6f61643f7374796c653d666c61742d737175617265)](https://github.com/ikechukwukalu/clamavfileupload/blob/main/LICENSE.md)

A simple File upload Laravel package with ClamAV anti-virus scan. This library was built riding on an existing clamav php library [kissit/php-clamav-scan](https://github.com/kissit/php-clamav-scan).

REQUIREMENTS
------------

[](#requirements)

- PHP 8.0+
- Laravel 9+
- Clamav

STEPS TO INSTALL
----------------

[](#steps-to-install)

```
composer require ikechukwukalu/clamavfileupload
```

- `php artisan vendor:publish --tag=cfu-config`

```
CLAMD_SOCK="/var/run/clamav/clamd.sock"
CLAMD_SOCK_LEN=20000
CLAMD_IP=null
CLAMD_PORT=3310
FILE_UPLOAD_INPUT=file
FILE_UPLOAD_DISK=public
FILE_UPLOAD_LOG_SCAN_DATA=false
HASHED=false
VISIBLE=true
```

- `php artisan vendor:publish --tag=cfu-migrations`
- `php artisan migrate`

### CLAMAV SCAN FILE UPLOAD

[](#clamav-scan-file-upload)

```
use Ikechukwukalu\Clamavfileupload\Facades\Services\FileUpload;

FileUpload::uploadFiles($request); //returns bool|FileUploadModel|EloquentCollection

/**
 * Default settings
 *
 * 'name' => null // This is different from file name
 * 'input' => config('clamavfileupload.input', 'file')
 * 'folder' => null
 * 'hashed' => config('clamavfileupload.hashed', false)
 * 'visible' => config('clamavfileupload.visible', true)
 * 'disk' => config('clamavfileupload.disk', 'local')
 *
 *
 */

/**
 * You can also overwrite the default settings with custom settings
 */
$settings = [
    'folder' => 'pdfs'
];

$fileUpload = new FileUpload;
$fileUpload::uploadFiles($request, $settings); //returns bool|FileUploadModel|EloquentCollection

/**
 * Access last scan results
 */
$fileUpload::getScanData()

/**
 * Check if upload was successful
 */
if (!$fileUpload::isSuccessful()) {
    echo $fileUpload::getErrorMessage();
}

/**
 * Make sure to save the $ref UUID so as to be
 * able to retrieve the uploaded file(s) from the database.
 */
$fileUpload::getRef()

/**
 * Soft delete files
 */

/**
 * @param string $ref
 * @return bool
 */
FileUpload::deleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
FileUpload::deleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
FileUpload::deleteOne($id, $ref);

/**
 * Permanently delete files from the database and disk
 */

/**
 * @param string $ref
 * @return bool
 */
FileUpload::forceDeleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
FileUpload::forceDeleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
FileUpload::forceDeleteOne($id, $ref);
```

### QUEUED CLAMAV SCAN FILE UPLOAD

[](#queued-clamav-scan-file-upload)

This process stores the file in a `tmp` directory and sets up a queue for the clamav scan and uploads the `tmp` files to their designated directory. At the end of the process temp files would have been removed from the `tmp` directory.

- To use `Redis` set `REDIS_CLIENT=predis` and `QUEUE_CONNECTION=redis` within your `.env` file.
- `php artisan queue:work`

```
use Ikechukwukalu\Clamavfileupload\Facades\Services\QueuedFileUpload;

QueuedFileUpload::uploadFiles($request); //returns bool|FileUploadModel|EloquentCollection

/**
 * Default settings
 *
 * 'name' => null // This is different from file name
 * 'input' => config('clamavfileupload.input', 'file')
 * 'folder' => null
 * 'hashed' => config('clamavfileupload.hashed', false)
 * 'visible' => config('clamavfileupload.visible', true)
 * 'disk' => config('clamavfileupload.disk', 'local')
 *
 *
 */

/**
 * You can also overwrite the default settings with custom settings
 */
$settings = [
    'folder' => 'pdfs'
];

$fileUpload = new QueuedFileUpload;
$fileUpload::uploadFiles($request, $settings); //returns bool|FileUploadModel|EloquentCollection

/**
 * Make sure to save the $ref UUID so as to be
 * able to retrieve the uploaded file(s) from the database.
 */
$fileUpload::getRef()

/**
 * Soft delete files
 */

/**
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::deleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::deleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::deleteOne($id, $ref);

/**
 * Permanently delete files from the database and disk
 */

/**
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::forceDeleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::forceDeleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
QueuedFileUpload::forceDeleteOne($id, $ref);
```

### NO CLAMAV SCAN FILE UPLOAD

[](#no-clamav-scan-file-upload)

```
use Ikechukwukalu\Clamavfileupload\Facades\Services\NoClamavFileUpload;

NoClamavFileUpload::uploadFiles($request); //returns bool|FileUploadModel|EloquentCollection

/**
 * Default settings
 *
 * 'name' => null // This is different from file name
 * 'input' => config('clamavfileupload.input', 'file')
 * 'folder' => null
 * 'hashed' => config('clamavfileupload.hashed', false)
 * 'visible' => config('clamavfileupload.visible', true)
 * 'disk' => config('clamavfileupload.disk', 'local')
 *
 *
 */

/**
 * You can also overwrite the default settings with custom settings
 */
$settings = [
    'folder' => 'pdfs'
];

$fileUpload = new NoClamavFileUpload;
$fileUpload::uploadFiles($request, $settings); //returns bool|FileUploadModel|EloquentCollection

/**
 * Check if upload was successful
 */
if (!$fileUpload::isSuccessful()) {
    echo $fileUpload::getErrorMessage();
}

/**
 * Make sure to save the $ref UUID so as to be
 * able to retrieve the uploaded file(s) from the database.
 */
$fileUpload::getRef()

/**
 * Soft delete files
 */

/**
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::deleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::deleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::deleteOne($id, $ref);

/**
 * Permanently delete files from the database and disk
 */

/**
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::forceDeleteAll($ref);

/**
 * @param array $ids
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::forceDeleteMultiple($ids, $ref);

/**
 * @param int $id
 * @param string $ref
 * @return bool
 */
NoClamavFileUpload::forceDeleteOne($id, $ref);
```

### HASH

[](#hash)

If the `HASHED` param within your `.env` is set to `true` the `file_name`, `path` and `url` fields will be encrypted before they are saved into the DB. The stored file will also be encrypted.

It might be helpful to extend the Model file `Ikechukwukalu\Clamavfileupload\Models\FileUpload` and add the following code:

```
use Illuminate\Support\Facades\Crypt;

    protected function getFileNameAttribute($value)
    {
        if ($this->hashed) {
            return Crypt::decryptString($value);
        }

        return $value;
    }

    protected function getPathAttribute($value)
    {
        if ($this->hashed) {
            return Crypt::decryptString($value);
        }

        return $value;
    }

    protected function getRelativePathAttribute($value)
    {
        if ($this->hashed) {
            return Crypt::decryptString($value);
        }

        return $value;
    }

    protected function getUrlAttribute($value)
    {
        if ($this->hashed) {
            return Crypt::decryptString($value);
        }

        return $value;
    }
```

Sample codes to view and download encrypted file:

```
use Illuminate\Http\Request;
use Ikechukwukalu\Clamavfileupload\Models\FileUpload as FileUploadModel;
use Symfony\Component\HttpFoundation\StreamedResponse;

Route::get('/download/hashed/file/{id}', function (Request $request, $id): StreamedResponse {
    $file = FileUploadModel::where('id', $id)->first()

    return response()->streamDownload(function () use($file) {
        echo Crypt::decrypt(Storage::disk($file->disk)->get($file->relative_path));
    }, "{$file->name}{$file->extension}");
});

Route::get('/view/hashed/file/{id}', function (Request $request, $id) {
    $file = FileUploadModel::where('id', $id)->first();
    $decrypted = Crypt::decrypt(Storage::disk($file->disk)->get($file->relative_path));

    header("Content-type: {$file->mime_type}");
    echo $decrypted;
});
```

EVENTS
------

[](#events)

```
/**
 * Dispatches when FileUpload::uploadFiles()
 * is called.
 *
 */
\Ikechukwukalu\Clamavfileupload\Events\ClamavFileScan::class

/**
 * Dispatches when QueuedFileUpload::uploadFiles()
 * is called.
 *
 * @param  array  $tmpFiles
 * @param  array  $settings
 * @param  string  $ref
 */
\Ikechukwukalu\Clamavfileupload\Events\ClamavQueuedFileScan::class

/**
 * Dispatches when all files scanned are safe.
 *
 * @param  array  $scanData
 */
\Ikechukwukalu\Clamavfileupload\Events\FileScanPass::class

/**
 * Dispatches when a file scanned has a problem.
 *
 * @param  array  $scanData
 */
\Ikechukwukalu\Clamavfileupload\Events\FileScanFail::class

/**
 * Dispatches when files have been stored and saved into the Database.
 *
 * @param  FileUploadModel|EloquentCollection $files
 * @param  string  $ref
 */
\Ikechukwukalu\Clamavfileupload\Events\SavedFilesIntoDB::class

/**
 * Dispatches when clamav is not running.
 *
 */
\Ikechukwukalu\Clamavfileupload\Events\ClamavIsNotRunning::class

/**
 * Dispatches when file soft delete fails.
 *
 * @param  array  $data
 */
\Ikechukwukalu\Clamavfileupload\Events\FileDeleteFail::class

/**
 * Dispatches when file soft delete passes.
 *
 * @param  array  $data
 */
\Ikechukwukalu\Clamavfileupload\Events\FileDeletePass::class

/**
 * Dispatches when permanent file delete from database and disk fails.
 *
 * @param  array  $data
 */
\Ikechukwukalu\Clamavfileupload\Events\FileForceDeleteFail::class

/**
 * Dispatches when permanent file delete from database and disk passes.
 *
 * @param  array  $data
 */
\Ikechukwukalu\Clamavfileupload\Events\FileForceDeletePass::class

/**
 * Dispatches when a QueuedFileUpload::deleteAll($ref) is called.
 *
 * @param  string  $ref
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteAll::class

/**
 * Dispatches when a QueuedFileUpload::deleteMultiple($ids, $ref) is called.
 *
 * @param  string  $ref
 * @param  array  $ids
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteMultiple::class

/**
 * Dispatches when a QueuedFileUpload::deleteOne($id, $ref) is called.
 *
 * @param  string  $ref
 * @param  int|string  $id
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteOne::class

/**
 * Dispatches when a QueuedFileUpload::forceDeleteAll($ref) is called.
 *
 * @param  string  $ref
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteAll::class

/**
 * Dispatches when a QueuedFileUpload::forceDeleteMultiple($ids, $ref) is called.
 *
 * @param  string  $ref
 * @param  array  $ids
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteMultiple::class

/**
 * Dispatches when a QueuedFileUpload::forceDeleteOne($id, $ref) is called.
 *
 * @param  string  $ref
 * @param  int|string  $id
 */
\Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteOne::class
```

### NOTE

[](#note)

- When a single file scanned fails, the process is ended and every uploaded file is removed.
- Every batch of uploaded files has a `$ref` UUID assigned to them.
- When using `s3` disk, files are first stored in a `tmp` directory using the `local` disk where they will be scanned before being uploaded to the `s3` bucket
- Always add custom `s3` disks to the `s3_disk` array within the configurations file.
- Model file `Ikechukwukalu\Clamavfileupload\Models\FileUpload`

```
protected $fillable = [
    'ref',
    'name',
    'file_name',
    'size',
    'extension',
    'disk',
    'mime_type',
    'path',
    'url',
    'folder',
    'hashed',
];
```

PUBLISH LANG
------------

[](#publish-lang)

- `php artisan vendor:publish --tag=cfu-lang`

LICENSE
-------

[](#license)

The CFU package is an open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% 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 ~30 days

Recently: every ~43 days

Total

17

Last Release

746d ago

Major Versions

v1.0.7 → v2.0.02023-08-19

v2.0.6 → v3.0.02024-06-18

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v3.0.0PHP &gt;=7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/160470701?v=4)[ikay007](/maintainers/ikay007)[@Ikay007](https://github.com/Ikay007)

---

Top Contributors

[![monitecture](https://avatars.githubusercontent.com/u/100952206?v=4)](https://github.com/monitecture "monitecture (144 commits)")[![ikechukwukalu](https://avatars.githubusercontent.com/u/60310041?v=4)](https://github.com/ikechukwukalu "ikechukwukalu (1 commits)")[![nowodev](https://avatars.githubusercontent.com/u/43044740?v=4)](https://github.com/nowodev "nowodev (1 commits)")

---

Tags

laravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ikechukwukalu-clamavfileupload/health.svg)

```
[![Health](https://phpackages.com/badges/ikechukwukalu-clamavfileupload/health.svg)](https://phpackages.com/packages/ikechukwukalu-clamavfileupload)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)

PHPackages © 2026

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