PHPackages                             rundiz/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. rundiz/upload

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

rundiz/upload
=============

Upload single or multiple files with validations. (allowed file extensions, matched mime type, max file size, security scan, reserved file name, safe for web file name).

2.0.15(1y ago)277.0k↓50%6MITPHPPHP &gt;=5.3.0

Since May 5Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/Rundiz/upload)[ Packagist](https://packagist.org/packages/rundiz/upload)[ RSS](/packages/rundiz-upload/feed)WikiDiscussions version2 Synced 1mo ago

READMEChangelog (10)DependenciesVersions (16)Used By (0)

Upload Component
================

[](#upload-component)

PHP Upload.
Upload single or multiple files with validations.

Tested up to PHP 8.5.

Features
--------

[](#features)

- allowed file extensions
- matched mime type
- max file size
- max image dimensions
- security scan
    - external security scan such as virus scan
- reserved file name
- safe for web file name

[![Latest Stable Version](https://camo.githubusercontent.com/883434d609381e8c142add94203ac58cee30472002574fca0aa7a5f2e1fa45f8/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f75706c6f61642f762f737461626c65)](https://packagist.org/packages/rundiz/upload)[![License](https://camo.githubusercontent.com/0d82466e0418dc61d8306ceb98d4743715ad4e7644086c4130219a8f719dbc2e/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f75706c6f61642f6c6963656e7365)](https://packagist.org/packages/rundiz/upload)[![Total Downloads](https://camo.githubusercontent.com/5e0f904690c34bf1f86c14706139d3aab749337e2702100d7a5578b8850d376d/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f75706c6f61642f646f776e6c6f616473)](https://packagist.org/packages/rundiz/upload)

Example:
--------

[](#example)

upload.php

```
// You have to include/require files if you did not install it via Composer.
require_once __DIR__.DIRECTORY_SEPARATOR.'Rundiz'.DIRECTORY_SEPARATOR.'Upload'.DIRECTORY_SEPARATOR.'Upload.php';

if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
    $Upload = new \Rundiz\Upload\Upload('filename');
    $Upload->move_uploaded_to = '/path/to/your/uploaded-files';
    // Allowed for gif, jpg, png
    $Upload->allowed_file_extensions = array('gif', 'jpg', 'jpeg', 'png');
    // Max file size is 900KB.
    $Upload->max_file_size = 900000;
    // Max image dimensions (width, height) in pixels. The array values must be integer only.
    // Please note that this cannot check all uploaded files correctly. For example: You allowed to upload txt and jpg, the txt file will be pass validated for max dimension. To make it more precise, please check it again file by file after move uploaded files are completed done.
    $Upload->max_image_dimensions = array(1280, 720);
    // You can name the uploaded file to new name or leave this to use its default name. Do not included extension into it.
    $Upload->new_file_name = 'new-uploaded-name';
    // Overwrite existing file? true = yes, false = no
    $Upload->overwrite = false;
    // Web safe file name is English, number, dash, underscore.
    $Upload->web_safe_file_name = true;
    // Scan for embedded php or perl language?
    $Upload->security_scan = true;
    // If you upload multiple files, do you want it to be stopped if error occur? (Set to false will skip the error files).
    $Upload->stop_on_failed_upload_multiple = false;
    // You may set calculate hash file to false if file size is too large to prevent execution timeout. (This is new since 2.0.13).
    $Upload->calculate_hash_file = true;

    // Begins upload
    $upload_result = $Upload->upload();
    // Get the uploaded file's data.
    $uploaded_data = $Upload->getUploadedData();

    if ($upload_result === true) {
        echo 'Upload successfully.';
    }
    if (is_array($uploaded_data) && !empty($uploaded_data)) {
        echo ''.htmlspecialchars(stripslashes(var_export($uploaded_data, true))).'';
    }

    // To check for the errors.
    if (is_array($Upload->error_messages) && !empty($Upload->error_messages)) {
        echo 'Error!';
        foreach ($Upload->error_messages as $error_message) {
            echo ''.$error_message.''."\n";
        }// endforeach;
    }

    // To check for the errors and use your own text. (new in 2.0.1).
    if (is_array($Upload->error_codes) && !empty($Upload->error_codes)) {
       foreach ($Upload->error_codes as $errIndex => $errItem) {
           if (isset($errItem['code'])) {
               switch ($errItem['code']) {
                   case 'RDU_1':
                       echo 'You have uploaded the file that is larger than limit.';
                       break;
                   case 'RDU_xxx':
                       // See more in error_codes property to see its array format and all available error codes.
                       break;
               }// endswitch;
           }
       }// endforeach;
   }

    // To use your translation from raw error message in this class. (new in 2.0.5).
    if (is_array($Upload->error_messages) && !empty($Upload->error_messages)) {
        echo 'Error!';
        foreach ($Upload->errorMessagesRaw as $error_message) {
            if (isset($error_message['message']) && isset($error_message['replaces'])) {
                echo ''.vprintf(
                    gettext($error_message['message']), // this example use gettext to translate text.
                    $error_message['replaces']
                ).''."\n";
            }
        }// endforeach;
    }
}
```

test-upload-form.php

```
>

        Test file upload.

            Upload

```

### Example results of `getUploadedData()`

[](#example-results-of-getuploadeddata)

The uploaded files and moved successfully will be result in array with these key =&gt; value format.

```
array (
    0 =>
    array (
        'name' => '2016-01-23_00001.jpg',
        'extension' => 'jpg',
        'size' => 599923,
        'new_name' => '2016-01-23_00001.jpg',
        'full_path_new_name' => '/path/to/your/uploaded-files/2016-01-23_00001.jpg',
        'mime' => 'image/jpeg',
        'md5_file' => 'c18b22a64cc71e1b1dfc930009e5f970',
    ),
    1 =>
    array (
        'name' => '2016-01-24_00001.jpg',
        'extension' => 'jpg',
        'size' => 260488,
        'new_name' => '2016-01-24_00001.jpg',
        'full_path_new_name' => '/path/to/your/uploaded-files/2016-01-24_00001.jpg',
        'mime' => 'image/jpeg',
        'md5_file' => 'a1b2ac1f19949d22ad02c37545d5285f',
    ),
)
```

More example is in tests folder.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance57

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~224 days

Recently: every ~367 days

Total

15

Last Release

524d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1568262?v=4)[vee w,](/maintainers/ve3)[@ve3](https://github.com/ve3)

---

Top Contributors

[![ve3](https://avatars.githubusercontent.com/u/1568262?v=4)](https://github.com/ve3 "ve3 (57 commits)")

---

Tags

multiple-file-uploadmultiple-filesuploaduploadphp uploadsecure uploadupload single fileupload multiple filesupload arrayweb safe file name

### Embed Badge

![Health badge](/badges/rundiz-upload/health.svg)

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

###  Alternatives

[kartik-v/bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.

5.4k7.9M13](/packages/kartik-v-bootstrap-fileinput)[vich/uploader-bundle

Ease file uploads attached to entities

1.9k25.9M116](/packages/vich-uploader-bundle)[oneup/uploader-bundle

This Symfony bundle provides a server implementation for handling single and multiple file uploads using either FineUploader, jQuery File Uploader, YUI3 Uploader, Uploadify, FancyUpload, MooUpload, Plupload or Dropzone. Features include chunked uploads, orphanages, Gaufrette and Flysystem support.

6066.3M27](/packages/oneup-uploader-bundle)[kartik-v/yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 3.x, 4.x &amp; 5.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

2286.8M95](/packages/kartik-v-yii2-widget-fileinput)[marrouchi/upload-crop-image-bundle

Basic server side cropping behavior for Symfony2

121.1k](/packages/marrouchi-upload-crop-image-bundle)

PHPackages © 2026

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