Skip to content
jkuchar edited this page Sep 18, 2014 · 1 revision

MultipleFileUpload (shorter MFU) is an add-on that makes uploading thousands of huge files piece of cake. Just 4 simple steps and you will not need to deal with chunking, autentization of uploads or browser compatibility.

Thanks to multi-backend design you can change your file storage just by changing line in documentation. Currently allows you to pick up one of these storages SQLite3 (default), SQLite and **Dibi (MySQL, PostgreSQL, MSSql, ...).

This add-on also allows you to change UI library just by changing one config property. Currently are supported PlUpload, Uploadify, SwfUpload and standard HTML4 form fields. You can add more interfaces - than the best supported for client's browser will be automatically chosen.

Basic usage

$f = new Form($this,$name);

$f->addMultipleFileUpload("exampleUploadField1","Upload field 1", /*max num. of files*/ 20)
    ->addRule("MultipleFileUpload\MultipleFileUpload::validateFilled","You must upload at least one file")
    ->addRule("MultipleFileUpload\MultipleFileUpload::validateFileSize","Files you've selected are too big.", 1024); //kB

Unfortunatelly it is not possible to use Nette validation rules, because client JavaScript current do not support that.

When you call ->getValues() on MFU you just get array of FileUpload objects.

Instalation into your application


simple set-up guide on Github that uses Composer package.

Installation of an example application

simple set-up guide on Github

Structure of this add-on from bird view

This plugin is made by three parts. Multiple File Upload class, storage driver and UI module. MFU class is always present. UI modules implements UI and its back-end that communicates with storage driver. Storage driver stores safely data on server before they are processed by your form handler.

User Interfaces

Current supported interfaces are:

Interface Author License JavaScript required? Description
HTML4SingleUpload Honza Kuchař NewBSD No Implements standard HTML 4 upload fields
Plupload Honza Kuchař NewBSD Yes Implements plupload
SWFUpload Roman Vykuka NewBSD Yes ImplementsSwfUpload; více informací o tomto interface na fóru.
Uploadify Honza Kuchař NewBSD Yes ImplementsUploadify

Default interfaces are HTML4SingleUpload and Plupload. Yes, more than one. This will enable Fallback Controller that is part of the MFU that will automatically choose the best available UI module.

MultipleFileUpload::getUIRegistrator()
	->clear() /* Remove already registered interfaces (defaults) */
	->register("MFUUIHTML4SingleUpload")
	->register("MFUUIUploadify"); /* last has the highest priority */

Storage Drivers

Driver is class that stores files and upload information about them. This class must be thread-safe. If you want to use another one than default you must register it in boostrap.php.

MultipleFileUpload::setQueuesModel(new MFUQueuesSQLite3());

SQLite v. 3 (default)

Is simple to use driver that stores meta-data in SQLite database v. 3. You need to allow to write to sqlite database (chmod 0777).

SQLite v. 2

Is simple to use legacy driver that stores meta-data in SQLite database v. 2. You need to allow to write to sqlite database (chmod 0777).

Dibi

This driver is for bigger applications. Stores data in any of Dibi supported databases. You need to create database tables for yourself. To activate this driver simply add this to your boostrap.php:

Dibi::connect(array(
	"driver"   => "postgre",
	"host"     => "127.0.0.1",
	"dbname"   => "MFU",
	"schema"   => "public",
	"user"     => "postgres",
	"pass"     => "toor",
	"charset"  => "UTF-8"
));
MultipleFileUpload::setQueuesModel(new MFUQueuesDibi());

Log

This driver do not store anything but it will log all events into log files. Great for debugging UI module.

Browser support

Thanks to multi-interface design it is supported on ancient browsers as well as on the state-of-the-art ones.

Known problems

We are using Github Issues to track bugs.

How to contribute?

  • help us answering questions that will change face of MFU in future.
  • ask and answer questions on forum
  • send pull request
  • open issue on github with your problem
  • you can ask me for commit right if you consider contributing regulary