PHPackages                             farzad-forouzanfar/secure-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. [File &amp; Storage](/categories/file-storage)
4. /
5. farzad-forouzanfar/secure-upload

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

farzad-forouzanfar/secure-upload
================================

A secure file upload package with validation and antivirus integration.

v1.0.3(1y ago)67MITPHPPHP &gt;=7.4

Since Apr 4Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/FarzadForuozanfar/SecureUpload)[ Packagist](https://packagist.org/packages/farzad-forouzanfar/secure-upload)[ Docs](https://github.com/FarzadForuozanfar/SecureUpload)[ RSS](/packages/farzad-forouzanfar-secure-upload/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (6)Used By (0)

SecureUpload PHP
================

[](#secureupload-php)

SecureUpload is a secure file upload library for PHP that ensures files are safely uploaded to your server by performing a series of security validations. It includes checks for file existence, extension and MIME type validation, content scanning for malicious code, and optional antivirus scanning via ClamAV.

Features
--------

[](#features)

- **File Existence Check:** Ensures the uploaded file exists before processing.
- **Extension &amp; MIME Type Validation:** Verifies that files have valid extensions and corresponding MIME types.
- **Content Scanning:** Detects and prevents malicious scripts or code embedded in files.
- **Antivirus Integration:** Uses ClamAV (triggered via a Python script) to scan files for threats, with logging support if enabled.
- **PSR-4 Autoloading:** Fully compliant with Composer autoloading standards for easy integration.

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

[](#requirements)

- **PHP:** Version 7.4 or higher. ([PHP Official Website](https://www.php.net))
- **Python:** Required for antivirus scanning. ([Python Official Website](https://www.python.org))
- **ClamAV:** For antivirus scanning:
    - **macOS:** Install via [Homebrew](https://brew.sh) using: ```
        brew install clamav
        ```
    - **Linux:** Install using your distribution's package manager. For Ubuntu, for example: ```
        sudo apt-get install clamav
        ```
    - **Windows:** Download from the [ClamAV website](https://www.clamav.net/downloads#otherversions) and follow the installation instructions.

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

[](#installation)

SecureUpload is available via Composer. To install, run the following command in your project directory:

```
composer require farzad-forouzanfar/secure-upload
```

Alternatively, clone the repository:

1. Clone the repository:

```
git clone https://github.com/FarzadForuozanfar/SecureUpload.git
```

2. Navigate to the project directory:

```
cd SecureUpload
```

3. Install dependencies via Composer:

```
composer install
```

Configuration
-------------

[](#configuration)

1. **Environment Variables:**
    Create or update your `.env` file with the necessary configuration settings.
2. **Language Files:**
    Place your language files in the `lang/` directory (e.g., `lang/lang-en.php` or `lang/lang-fa.php`).
3. **Web Server Setup:**
    Configure your web server to serve the `public/` directory as the document root.

Usage
-----

[](#usage)

To use SecureUpload, simply include the Composer autoloader in your project and instantiate the uploader in your application code. For example, in your `public/index.php`

```
