How to increase the size of the file upload in Laravel Voyager Media Manager?

How to increase the size of the file upload in Laravel Voyager Media Manager?

Written by Bobby Iliev on Jan 5th, 2023 Views Report Post

Introduction

Laravel Voyager is a great open-source admin panel for Laravel. It is also the admin panel currently used in Laravel Wave which is a Laravel SaaS starter kit.

In this article, you will learn how to increase the size of the file upload in Laravel Voyager Media Manager.

PHP changes

First, you will need to increase the size of the file upload in the PHP configuration file. You can do this by editing the php.ini file and changing the upload_max_filesize and post_max_size values.

If you don't know where your php.ini file is located, you can create a new file called info.php and add the following code:

<?php
phpinfo();

Then, you can access the info.php file in your browser and it will show you the location of your php.ini file.

After you have increased the size of the file upload in the PHP configuration file, you will need to restart your web server. And then visit the info.php file again to make sure that the changes have been applied.

Dropzone.js changes

The Laravel Voyager Media Manager uses the Dropzone.js library to handle the file upload. So, you will need to increase the size of the file upload in the Dropzone definition.

The default size of the file upload in the Laravel Voyager Media Manager is 256MB.

For this, we will copy the media manager view file from the Laravel Voyager package to our project. You can do this by running the following command:

  • Create the resources/views/vendor/voyager/media directory if it doesn't exist:
mkdir -p resources/views/vendor/voyager/media
  • Copy the manager.blade.php file from the Laravel Voyager package to our project:
cp vendor/tcg/voyager/resources/views/media/manager.blade.php resources/views/vendor/voyager/media/manager.blade.php

Now, you can open the resources/views/vendor/voyager/media/manager.blade.php file and set the maxFilesize value to the desired size.

  • Open the file and go to line 847:
nano +847 resources/views/vendor/voyager/media/manager.blade.php

And inside the dropzone function add a new line and set the maxFilesize value to the desired size:

...
            dropzone.dropzone({
                // Add the line below
                maxFilesize: 500,
                timeout: 180000,
                url: '{{ route('voyager.media.upload') }}',
...

Save the file and you are done. After that go to the media manager page and do a hard refresh to make sure that the cache is cleared and try to upload a file that is larger than the default size.

Conclusion

In this article, you have learned how to increase the size of the file upload in Laravel Voyager Media Manager.

If you are building a SaaS application, you can use the Laravel Wave starter kit which will let you build a SaaS application quickly as it comes with a lot of features out of the box!

If you have any questions, feel free to ask them in the community forum at https://devdojo.com/forum.

Comments (0)