Download the PHP package tacoberu/nette-form-fileupload without Composer

On this page you can find all versions of the php package tacoberu/nette-form-fileupload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nette-form-fileupload

Nette form FileControl

FileControl and MultiFileControl are Nette form inputs for file uploading that behave exactly like other Nette inputs: setValue() sets the value, getValue() returns it, and validation, conditional validation, and error messages work identically to text or select inputs.

The standard <input type="file"> has several inconveniences when editing existing data:

  1. The original file cannot be shown in any reasonable way — unlike other inputs, where the original value can be displayed.
  2. Related to that is how to delete an existing file.
  3. When an unrelated error occurs elsewhere in the form, the user has to upload the file again.
  4. Uploading large files is a chapter of its own.

FileControl solves this:

  1. An existing file is represented by a value of the FileCurrent class. If the user deletes it, the form knows about it.
  2. Uploaded files are kept in a transaction — once uploaded, a file does not need to be uploaded again even if the form fails for another reason.

The input value can take one of three forms:

Version and requirements

Branch PHP Nette
v2.0 >= 8.1 ^3.2
v1.2 >= 7.4 ^3.1

Quick start

Register the extension in config.neon:

Use in a form:

A form with a single file (FileControl) — an uploaded file has a delete button:

A form with multiple files (MultiFileControl) — with image previews, deletion of individual items (✕) and the ↻ button for preloading:

Runnable examples are available in the examples/ directory.

Features

No-JS mode

The controls are fully functional without JavaScript. The ↻ button lets the user upload files before submitting the form — the page does a full round-trip, but all form state is preserved. Validation, errors, and the transaction mechanism all work the same way.

JS enhancements: AJAX upload and ↻ button helpers

The controls are fully functional without any JS (see above) — the ↻ button is visible and the user clicks it manually. On top of that baseline, assets/filecontrol.ts / assets/filecontrol.js offer optional JS enhancements that can be integrated into any frontend:

AJAX upload features (initMultiFileAjaxUpload / initFileAjaxUpload):

Validation

Works exactly like other Nette inputs — fully compatible with addConditionOn(), addRule(), and error messages:

Rule Description
Form::Required / setRequired() A file must be selected or already exist as FileCurrent.
Form::MaxFileSize Maximum file size in bytes.
Form::MimeType Allowed MIME types, e.g. 'image/jpeg' or an array of types.
Form::Image Shorthand for supported image formats (image/jpeg, image/png, image/gif, image/webp).

Upload errors


API

setPreviewer()

Sets a previewer for formatting file previews. GenericFilePreviewer displays image thumbnails.

getRemoveButtonPrototype()

Allows customizing the delete button: label, classes, title.

Transactions

An uploaded file is automatically moved to the storage (transaction). This means the file does not need to be uploaded again on a validation error. After successful processing, it is available via getValue() like any other value.

Once committed to the system, the transaction can be discarded explicitly:

Or it can be left to the GC, which deletes it automatically after UploadStoreTemp::$gcAgeLimit expires.

Building assets (TypeScript)

Compiled output: assets/filecontrol.js (symlinked into examples/document_root/js/).

E2E tests (Playwright)

The URL of the tested application is configured in .env via APP_URL. Outputs are saved to temp/.


All versions of nette-form-fileupload with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
nette/forms Version ^3.1
psr/http-message Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tacoberu/nette-form-fileupload contains the following files

Loading the files please wait ...