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

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

hkreuter/graphql-upload
=======================

A middleware to support file uploads in GraphQL. Forked from ecodev/graphql-upload.

6.1.0(5y ago)09.4k2MITPHPPHP ^7.2 || ^8.0

Since Jan 19Pushed 4y agoCompare

[ Source](https://github.com/hkreuter/graphql-upload)[ Packagist](https://packagist.org/packages/hkreuter/graphql-upload)[ RSS](/packages/hkreuter-graphql-upload/feed)WikiDiscussions master-OXDEV-4868 Synced 1w ago

READMEChangelogDependencies (6)Versions (18)Used By (0)

GraphQL Upload
==============

[](#graphql-upload)

[![Build Status](https://github.com/ecodev/graphql-upload/workflows/main/badge.svg)](https://github.com/ecodev/graphql-upload/actions)[![Code Quality](https://camo.githubusercontent.com/a8f05cc7962119fd9d4f3f67b8789301ed77f44d0817780e44b3b9749acc0935/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f45636f6465762f6772617068716c2d75706c6f61642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7b3ac0e699caafe35065bbae141ac0832b427f1449023ad8eb4d00cf57d099ec/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f45636f6465762f6772617068716c2d75706c6f61642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/bede706b070d442827228fc6ab27e139cf8badaa18a238375b8702ff8bce66dc/68747470733a2f2f706f7365722e707567782e6f72672f65636f6465762f6772617068716c2d75706c6f61642f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ecodev/graphql-upload)[![Latest Stable Version](https://camo.githubusercontent.com/fa68f85be79dffa509f263f9b06a60e74b3acc3347782d7cbf2e50860c487712/68747470733a2f2f706f7365722e707567782e6f72672f65636f6465762f6772617068716c2d75706c6f61642f762f737461626c652e706e67)](https://packagist.org/packages/ecodev/graphql-upload)[![License](https://camo.githubusercontent.com/ec34e22eb182c733cbbe100730a05a4a6cd89c28e2b0f5513aad6ad6a1e01b58/68747470733a2f2f706f7365722e707567782e6f72672f65636f6465762f6772617068716c2d75706c6f61642f6c6963656e73652e706e67)](https://packagist.org/packages/ecodev/graphql-upload)[![Join the chat at https://gitter.im/Ecodev/graphql-upload](https://camo.githubusercontent.com/e1cb5d424041ef4148f8707608fcd2a6ce99cfb56bf5129a39f8b3d46a91e180/68747470733a2f2f6261646765732e6769747465722e696d2f45636f6465762f6772617068716c2d75706c6f61642e737667)](https://gitter.im/Ecodev/graphql-upload)

A [PSR-15](https://www.php-fig.org/psr/psr-15/) middleware to support file uploads in GraphQL. It implements [the multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec)for [webonyx/graphql-php](https://github.com/webonyx/graphql-php).

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

[](#quick-start)

Install the library via composer:

```
composer require ecodev/graphql-upload
```

### Configure as middleware

[](#configure-as-middleware)

In Laminas Mezzio, it would typically be in `config/routes.php` something like:

```
use Application\Action\GraphQLAction;
use Mezzio\Helper\BodyParams\BodyParamsMiddleware;
use GraphQL\Upload\UploadMiddleware;

$app->post('/graphql', [
    BodyParamsMiddleware::class,
    UploadMiddleware::class, // This is the magic
    GraphQLAction::class,
], 'graphql');
```

#### Other frameworks

[](#other-frameworks)

This lib is an implementation of PSR-15, so it can be used with any framework supporting PSR-15. For specific configuration instructions, refer to your framework documentation.

If your framework does not support PSR-15 middleware, you will probably need some kind of bridge. Again, refer to your framework for specific instructions. Or else, you could use the direct usage below for manual integration.

### Direct usage

[](#direct-usage)

If you don't use middleware, it can be called directly like so:

```
