PHPackages                             sytxlabs/filesanitizer - 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. [Security](/categories/security)
4. /
5. sytxlabs/filesanitizer

ActiveLibrary[Security](/categories/security)

sytxlabs/filesanitizer
======================

A PHP library to sanitize file names and content to prevent security vulnerabilities.

1.1.0(3mo ago)1814↑29.2%12MITPHPPHP &gt;=8.1CI passing

Since Mar 16Pushed 3mo agoCompare

[ Source](https://github.com/SytxLabs/FileSanitizer)[ Packagist](https://packagist.org/packages/sytxlabs/filesanitizer)[ Docs](https://sytxlabs.eu)[ RSS](/packages/sytxlabs-filesanitizer/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (2)

FileSanitizer
=============

[](#filesanitizer)

[![MIT Licensed](https://camo.githubusercontent.com/c2bffd81d308ced1cc3b0d66fb0ed453ab478a5e17c988b780f9de986a390ee2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Check code style](https://github.com/SytxLabs/FileSanitizer/actions/workflows/code-style.yml/badge.svg?style=flat-square)](https://github.com/SytxLabs/FileSanitizer/actions/workflows/code-style.yml)[![Tests](https://github.com/SytxLabs/FileSanitizer/actions/workflows/tests.yml/badge.svg?style=flat-square)](https://github.com/SytxLabs/FileSanitizer/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/f2a2f6564168346db91662a2aa64254de4e92f9a8342ff21155a562e0a9ec53d/68747470733a2f2f706f7365722e707567782e6f72672f737974786c6162732f66696c6573616e6974697a65722f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/sytxlabs/filesanitizer)[![Total Downloads](https://camo.githubusercontent.com/27de230ff3d4e107018c3aa0baad470b90c92491043c17c1cf06943010aa0b24/68747470733a2f2f706f7365722e707567782e6f72672f737974786c6162732f66696c6573616e6974697a65722f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/sytxlabs/filesanitizer)

Pure PHP file sanitizer and scanner for uploaded files. It strips metadata where practical, rewrites selected file types into safer forms, and detects suspicious or malicious content such as XSS-style payloads, risky embedded markup, active PDF content, and dangerous archive entries.

Features
--------

[](#features)

- Re-encodes supported image formats to remove metadata and ancillary chunks
- Sanitizes HTML and SVG using strict policy-based cleanup
- Scans PDFs for active content and applies best-effort cleanup
- Scans OOXML documents for risky content such as macros, ActiveX, and external relationships
- Recursively scans ZIP archives, including nested archives, with configurable safety limits
- Scans audio files for suspicious embedded payloads and removes metadata where practical
- Scans video files for suspicious embedded payloads and applies best-effort metadata cleanup
- Supports sanitize-always mode for best-effort cleaning even when risky content is detected
- Pure PHP implementation with no shell access, SSH, or external binaries required

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

[](#installation)

```
composer require sytxlabs/filesanitizer
```

For development and tests:

```
composer install
composer test
```

Quick start
-----------

[](#quick-start)

```
