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

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

i-ismail/laravel-file-upload
============================

Laravel file upload is a package that allows to you upload a single file or multiple files with auto-optimization and resizing

v1.6(1y ago)118MITPHPPHP ^8.2

Since Feb 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Ibrahim779/larave-file-upload)[ Packagist](https://packagist.org/packages/i-ismail/laravel-file-upload)[ RSS](/packages/i-ismail-laravel-file-upload/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (5)Versions (10)Used By (0)

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

[](#file-upload-service)

#### Description

[](#description)

Laravel file upload is a package that allows to you upload a single file or multiple files with auto-optimization, resizing, uses a smart combination of the best optimization and lossy compression algorithms to shrink images to the minimum possible size while keeping the required level of quality.

[![Laravel File Upload](laravel-file-upload.png)](laravel-file-upload.png)

#### Installation

[](#installation)

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

```

#### Publish Config File

[](#publish-config-file)

```
php artisan vendor:publish --tag=file-upload-config

```

#### Packages dependency

[](#packages-dependency)

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 all methods in intervention image package.
- it provide auto-optimization and resizing.

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 folder path.

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

$post->save();
```

You can add disk, by default disk is public.

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

$post->save();
```

You can add custom file name.

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

$post->save();
```

You can add custom extension, By default, we will set this value to "webp" for images.

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

$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');
$post->save();
```

You can ***delete file***

```
$post = Post::find(1);
//...
$post->image = FileUpload::delete($post->image);
```

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 auto-optimization and resizing.

#### Preparing the database

[](#preparing-the-database)

You need to publish the migration to create the media table:

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

```

After that, you need to run migrations.

```
php artisan migrate

```

#### Publishing the config file

[](#publishing-the-config-file)

Publishing the config file is optional:

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

```

#### Preparing your model

[](#preparing-your-model)

```
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Post 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('images'))->setModel($post)->store();
```

You can add collection.

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

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

You can add disk, by default disk is public.

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

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

***You can use all methods in intervention image package before setModel method***

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

***You can use all methods in media library package after setModel method***.

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

#### Retrieving media

[](#retrieving-media)

```
$post->getMedia('posts'); // posts is collection name.
```

This method returns a collection of Media-objects.

retrieving the first media and the URL for the first media.

```
$post->getFirstMedia('posts');

$post->getFirstMediaUrl('posts');
```

#### Delete media

[](#delete-media)

You can remove something from the library by simply calling delete on an instance of Media:

```
$mediaItem->delete();
```

Delete Model

```
$post->delete(); // all associated files will be deleted as well.

$post->deletePreservingMedia(); // all associated files will be preserved.
```

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

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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 ~38 days

Recently: every ~0 days

Total

9

Last Release

563d ago

PHP version history (2 changes)v1.0PHP ^7.4|^8.1

v1.2PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![Ibrahim779](https://avatars.githubusercontent.com/u/55800801?v=4)](https://github.com/Ibrahim779 "Ibrahim779 (24 commits)")

---

Tags

laravelfileupload

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k14.2M62](/packages/knuckleswtf-scribe)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[api-platform/laravel

API Platform support for Laravel

58170.4k13](/packages/api-platform-laravel)[slimani/filament-media-manager

A media manager plugin for Filament.

126.9k](/packages/slimani-filament-media-manager)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)[erlandmuchasaj/laravel-file-uploader

A simple package to help you easily upload files to your laravel project.

139.2k](/packages/erlandmuchasaj-laravel-file-uploader)

PHPackages © 2026

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