Download the PHP package undjike/nmfs-uploads without Composer
On this page you can find all versions of the php package undjike/nmfs-uploads. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download undjike/nmfs-uploads
More information about undjike/nmfs-uploads
Files in undjike/nmfs-uploads
Package nmfs-uploads
Short Description This package allows you to perform uploads of no matter file size to your PHP server
License MIT
Informations about the package nmfs-uploads
Nmfs-uploads (No Matter File Size Uploads to your PHP server)
Introduction
Nmfs-uploads package allows you to perform uploads of no matter file size to your PHP server.
You certainly know that the default PHP server's configuration limits the size of files upload to 2 Mb maximum. With this package, you need not to change the default configuration in your php.ini or other.
Nmfs-uploads package provides you with some tools and implements chunk uploads. This means that whatever size the file to upload is, the server will chunk the file in small parts of size under 2 Mb and automatically will merge the parts at the end.
Installation
Require this package with composer using the following command:
After updating composer, add the service provider to the providers
array in config/app.php
if you are using a Laravel version under 5.5.
Laravel 5.5 or later version uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
After installing the package via composer, you will need to publish the configurations of the package. Use the following artisan command:
This will publish all the necessaries for the package to work and some files to demonstrate how to use this package.
Now, you can just visit your server page at /uploads
(with your Laravel Development Server : localhost:8000/uploads
) to have a demonstration of how this stuff works.
Usage
Configuration publication will generate for you:
-
A configuration file in the config directory of your project,
config/nmfs-uploads.php
. -
A sample controller
app/Http/Controllers/NmfsUploadsController.php
with two methodsindex
andperform
. - A view
resources/views/nmfs-uploads.blade.php
that is a sample page to perform your uploads.
The view uses a dropzone for you to just drag and drop your files for them to be uploaded to your server.
As seen in the extract above, the index
method of the controller simply return this view.
- As you may have guessed, two
routes
are added to yourweb.php
.
The first, named upload
with a GET
method used for displaying the upload page and the second with a POST
, to which upload requests will be sent.
-
Finally, the package provides some assets in
public/vendor/nmfs-uploads
.your-project/ └───public/ └───vendor/ └───nmfs-uploads/ └───blueimp-canvas-to-blob/ └───blueimp-file-upload/ └───blueimp-load-image/ └───blueimp-tmpl/ └───bootstrap/ └───fontawesome-free/ └───jquery/ └───nmfs-client.js └───style.css
Most of these assets are used for beautifully rendering your upload page.
We needed to provide bootstrap
and jQuery
to ensure it will be available for the package. If you already got it, feel free to delete these directories and replace the links in the upload view.
All of blueimp
directories are used to perform the main stuff of the package. If you need to know more about the package, browse to blueimp.
Understanding
The recieve
closure in the perform
method of the controller allow you to perform some actions after an upload is successfully done.
By default, uploads are stored in a public directory temps
. You are free to change this. The name temps
is only given because it's usual to get an upload there an to move it in a self-made library. Personally, we did this several times with spatie/laravel-medialibrary.
Surely, you must have realized that urls in configuration files are set to null
by default. This is done on purpose.
To allow you to take a very light use of the package, when upload url is set to null
, the package uses the current url to post the upload.
This can be very useful when using multiple upload pages. Meaningfully, the url to display the upload page is the same to which the file will be posted.
You should be aware that the client side of the package is made in jQuery, so if you are not satisfied by the page design or you want to customize some aspects, edit public/vendor/nmfs-uploads/nmfs-client.js
.
Note
Some of the configurations and restrictions clauses can be declare in both client and server side. It may be useful when working with multiple clients with different access level.
For any question or issue with this package, extend me a message and it will be a pleasure to solve the problem.
License
Nmfs-uploads is distributed under MIT license.