PHPackages                             i-neop/laravel-file-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. i-neop/laravel-file-upload

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

i-neop/laravel-file-upload
==========================

laravel file upload is package that provides to you upload single file or multi files

4139PHP

Since Aug 28Pushed 3y ago2 watchersCompare

[ Source](https://github.com/IbrahimNeop2022/laravel-file-upload)[ Packagist](https://packagist.org/packages/i-neop/laravel-file-upload)[ RSS](/packages/i-neop-laravel-file-upload/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

File Upload Service
===================

[](#file-upload-service)

#### Installation

[](#installation)

```
composer require i-neop/laravel-file-upload

```

open your Laravel config file config/app.php and add the following lines.

In the *$providers* array add the service providers for this package.

```
Intervention\Image\ImageServiceProvider::class

```

Add the facade of this package to the *$aliases* array.

```
'Image' => Intervention\Image\Facades\Image::class

```

publish media library migrations

```
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migrate

```

publish config

```
php artisan vendor:publish --provider="INeop\FileUpload\Providers\FileUploadServiceProvider" --tag="file-upload-config"

```

1. [Intervention Image documentation](https://image.intervention.io/v2).
2. [Laravel-media library documentation](https://spatie.be/docs/laravel-medialibrary).

### 1- FileUploadService class

[](#1--fileuploadservice-class)

*this class store file and return file name to store it in your model*.

- it provide hash name for file
- it provide auto resize image
- it provide all methods in intervention image package.
- it provide config file to set max width, max height and quality.

Here are a few short examples of what you can do:

```
$post = new Post();
//...
$post->image = FileUpload::make(request('image'))->store();
$post->save();
```

You can add path and disk, by default disk is public.

```
$post = new Post();
//...
$post->image = FileUpload::make(request('image'))->store('posts', 's3');
$post->save();
```

You can use ***all methods in intervention image package***.

```
$post = new Post();
//...
$post->image = FileUpload::make(request('image'))
                    ->resize(400, 400)
                    ->crop(100, 100, 25, 25)
                    ->store('posts', 's3');
$post->save();
```

You can use ***delete old file***, for example in update.

```
$post = Post::find(1);
//...
$post->image = FileUpload::make(request('image'))
                    ->delete($post->image)
                    ->store('posts');
$post->save();
```

You can get path.

```
$post = new Post();
//...
$fileUpload = FileUpload::make(request('image'));
$post->image = $fileUpload->store('posts');
$filePath = $fileUpload->getFilePath();

$post->save();
```

**Note:** you can clean code by Accessors &amp; Mutators

```
$post = Post::create([
        //...
]);

//In Post Model
public function setImageAttribute($image)
{
    $this->attributes['image'] = FileUpload::make($image)->store('posts');
}
```

To get image.

```
//In Post Model
public function getImgAttribute()
{
    return $this->image ? asset('storage/'. $this->image) : asset('images/post.jpg');
}
```

***Dont forget*** run this command.

```
php artisan storage:link

```

---

### 2- MediaUploadService class

[](#2--mediauploadservice-class)

*this class use media-library package to store media files for your model*.

- it provide all methods in intervention image package.
- it provide all methods in media-library package.
- it provide upload multiple files.
- it provide config file to set max width, max height and quality.

To associate media with a model, the model must implement the following interface and trait:

```
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class YourModel extends Model implements HasMedia
{
    use InteractsWithMedia;
}
```

Here are a few short examples of what you can do:

```
$post = new Post();
//...
$post->save();
MediaUpload::make(request('image'))->setModel($post)->store();
```

You can add collection and disk, by default disk is public.

```
$post = new Post();
//...
$post->save();
MediaUpload::make(request('image'))->setModel($post)->store('image', 's3');
```

You can upload multiple files.

```
$post = new Post();
//...
$post->save();

MediaUpload::make(request('files'))->setModel($post)->store('images');
```

You can use ***all methods in intervention image package***.

```
$post = new Post();
//...
$post->save();
MediaUpload::make(request('image'))
    ->resize(500, 200)
    ->crop(100, 100, 25, 25)
    ->setModel($post)
    ->store('image', 's3');
```

You can use ***all methods in media library package***.

```
$post = new Post();
//...
$post->save();
MediaUpload::make(request('image'))
    ->resize(500, 200)
    ->setModel($post)
    ->usingName('my-image-name')
    ->withCustomProperties([
        'primaryColor' => 'red',
        'image-code'  => '12458558',
    ])
    ->store('image');
```

To retrieve files you can use the getMedia-method:

```
    $mediaItems = $yourModel->getMedia();
```

the getFirstMedia and getFirstMediaUrl convenience-methods are also provided:

```
    $media = $yourModel->getFirstMedia();
    $url = $yourModel->getFirstMediaUrl();
```

If you want to remove all associated media in a specific collection you can use the clearMediaCollection method. It also accepts the collection name as an optional parameter:

```
    $yourModel->clearMediaCollection(); // all media will be deleted
    $yourModel->clearMediaCollection('images'); // all media in the images collection will be deleted
```

***recommend:*** read [Laravel-media library documentation](https://spatie.be/docs/laravel-medialibrary).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d38d17fc23657b507b4cd67e279f9ea3284471ee09c166413210d9c70d66c599?d=identicon)[IbrahimNeop2022](/maintainers/IbrahimNeop2022)

---

Top Contributors

[![IbrahimNeop2022](https://avatars.githubusercontent.com/u/96335805?v=4)](https://github.com/IbrahimNeop2022 "IbrahimNeop2022 (11 commits)")

### Embed Badge

![Health badge](/badges/i-neop-laravel-file-upload/health.svg)

```
[![Health](https://phpackages.com/badges/i-neop-laravel-file-upload/health.svg)](https://phpackages.com/packages/i-neop-laravel-file-upload)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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