doublemcz/nette-plupload

Installs: 89

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 3

Language:JavaScript

1.0.2 2015-12-30 19:45 UTC

This package is not auto-updated.

Last update: 2024-06-08 15:00:35 UTC


README

Nette Plupload can be installed over composer.

Installation

composer require doublemcz/nette-plupload

Copy folder 'public' from 'src' dir to your www folder and set right path in links in HTML document.

Usage

Add to @layout.latte

Put includes to your html. Package needs jQuery to work

<link rel="stylesheet" href="{$basePath}/pathToPluploadPublicFolder/css/nette.plupload.css">
<!--- If you have jQuery in your project already, you can omit following include -->
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="{$basePath}/pathToPluploadPublicFolder/js/plupload.full.min.js"></script>
<!-- Based on your language choose your language code, you can see possible languages in 'public/langs' folder -->
<script src="{$basePath}/pathToPluploadPublicFolder/js/langs/cs.js"></script>
<script src="{$basePath}/pathToPluploadPublicFolder/js/jquery.nette.plupload.js"></script>

NettePlupload is automatically initialized by event in jquery.nette.plupload.js

In Presenter
public function createComponentUploadForm($name)
{
	$form = new \Doublemcz\NettePlupload\Form($this, $name);
	$form->addPlupload('plupload');
	$form->addSubmit('submit', 'Send form');
	$form->onSuccess[] = [$this, 'onSuccess'];

	return $form;
}

public function onSuccess(Form $form)
{
	$files = $form->getValues()->plupload;
	foreach ($files as $file) {
	  // work with uploaded file
	}
}
In latte
{form uploadForm}
  {input plupload}
  {input submit}
{/form}