Download the PHP package seblhaire/uploader without Composer

On this page you can find all versions of the php package seblhaire/uploader. 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 uploader

Uploader

By Sébastien L'haire

A Laravel library to provide file upload utilities. A Javascript library builds a complete file upload widget with upload button, drag-and-drop zone, progress bar and result builder. A controller is available to manage uploaded files.

It uses:

Demo site available here.

Installation

  1. composer require seblhaire/uploader

  2. Composer will automatically link the package with Laravel. But you still can explicitely add provider and facade to your config/app.php:

  3. Publish package (optionally).

  4. Set storage link (optionally, see Laravel doc)

  5. For Javascript and stylesheets, see next section.

Javascript and stylesheets

On a webpage, every JS library and CSS stylesheets can be linked separately. If you choose this classical way, first dowload and install above mentionned libraries. Then publish package files as explained above and put following tags in your template:

But websites often use many libraries and stylesheets and browser must download many files before the site can be rendered properly. Modern websites come with a single compressed Javascript file which concatenates necessary scripts; same principle for stylesheets. With Laravel you can use Laravel Mix to compile files.

Use NPM package manager : npm install bootstrap jquery clipboard @fortawesome/fontawesome-free

Then your js source file should be something like this:

UploadedFileContainerExt is optional, since you can write your own result processor and your own file container.

For your stylesheet:

Configuration file

Uploader library is customizable. Default values can be changed, either in configuration file, or by passing options in Facade function (see next section). If you want to modify default configuration file, publish package files and access to config/uploader.php.

Usage

Uploader package comes with a simple Facade.

Link to Facade:

use Seblhaire\Uploader\UploaderHelper;

UploaderHelper::init

Inits a uploader PHP object that can be passed to the view to set the uploader properly.

UploaderHelper::init($uploaderElement, $label, $url, $options = array(), $additionalParams = array())

where:

Uploader sends data to a controller (see below) which accepts parameters to set filename, file systems storage name and file path. Since these values are usually set dynamically, Uploader Javascript object provides methods to set them; the PHP object built by our Facade provides methods to insert Javascript code properly, for instance in Ajax scripts.

Get uploader

getUploader()

Prints javascript code to get uploader class.

Set path name

setPath($path, $is_string = true)

Find further explanation here.

Set file pattern

setfilepattern($filename)

Define a pattern to build file names for uploaded files that replace original file name. Find further explanation here.

Set file system storage name

setstoragename($storagename)

Uploader uses Laravel file system. $storagename must be one of the storage names stored of your application config/filesystems.php. Find further explanation here.

Set maximum file site

setmaxsize($size)

Defines a maximum file size in KB.

Set accepted file types

setmimes($mimes)

Accepts a string of accepted, comma-separated, file extensions.

Set rename permission

setrename($val)

Defines if we rename current file if a file with same name already exists in upload directory. Accepts boolean variable or string 'true' or 'false'.

Reset uploader

reset()

empties files list.

Get result processor

getresultprocessor()

After upload success, Uploader returns a Result processor, which is a Javascript object. See details here. You may need to access to the result processor attached to your Uploader, for instance to add files already uploaded in previous processes. In this case, insert following in your view:

var proc = {!! $uploader->getresultprocessor() !!};

Show uploader

showall()

Displays uploader entirely if parts or whole have been hidden.

showuploader()

Displays uploader button and zone if has been hidden.

Hide uploader completely

hideall()

Hides uploader zone and uploader label.

hideuploader()

Hides uploader zone

Toggle display

toggleall()

If whole uploader is visible, hide it, show it if hidden.

toggleuploader()

If uploader zone is visible, hide it, show it if hidden.

Summary

To summarize, in your controller insert:

In your blade template, insert following at the place you want your uploader to appear:

{!! $uploader !!}

If you need to set form parameters or add files in result list, you can use methods shown above. In this case, we insert them in document ready clause but you will generally use it in an Ajax function:

Uploader result class

File processing depends strongly on your web app purposes. Therefore it is impossible to provide a complete uploader package that satisfies all needs. We provide useful functions instead.

Uploader uses a result class to deal with upload results returned by controller. Package contains a result class UploadresultProcessor stored in resources/js/upload.js that can be replaced or extended.

Mandatory class properties and function are:

A file container is a class that builds a <div> inside the file list <div>. Class name is defined in uploader parameter filecontainer. It must have following methods:

In resources/js/upload.js, you can find file container UploadedFileContainer which is used by default by our uploader. It builds a very simple container with basic file information. We have also added a url buiding utilty buildurl(file, info) which can be used in your own class extension. File url are built following these rules:

In resources/js/UploadedFileContainerExt.js we define class UploadedFileContainerExt which extends UploadedFileContainer and builds a nice file container, with image thumbnail and provides other functionalities, such as file url copy and file delete processor that calls route defined in uploader parameter delurl removing file in file result container filelist.

Controller

Uploader package comes with helpers that help you build your controller methods easily. We use Laravel file storage system. Files can be stored for instance in public folder to be used in website or in storage system for other purposes.

Further examples can be found here.

Validation rules

We have built two Laravel validation rules that are useful for our uploader.

FileuploadRequest is a custom request validation rule that verify our uploader fields. It can extended if you need to validate your additional parameters:

Protected trait functions

We have defined protected methods in UploaderTrait that can be used in your controller as follows.

buildFileObj($filename)

Builds a simple stdClass object from file name with fields name and ext that will be used by other functions in trait.

buildUniqueFileName($disk, $path, $fileobj, $separator = '-')

This function builds an unique file name in upload directory.

cleanFileName($filename)

Remove accentuated characters abd white spaces from file name.

getPath($request)

Returns file path defined from default config files or from uploader parameters.

getDisk($request, $path)

Return storage name either from default config files or from uploder parameters and creates directory from path.

Translation keys

Laravel loads config files very early in process. Therefore config files cannot contain __('translation.key'). In order to solve this issue, we made an helper either to print directly strings or to send translation key to translation helper. Translation keys can be delimited by character # . Ex: "uploader::messages.uploadtext". Original translations are stored under vendor/seblhaire/uploader/resources/lang. If you publish package files, you can find translations in resources/lang/vendor/uploader/.

Feel free to translate keys in your own language and either to send it to the author or to do a merge request on GitHub.

Questions? Contributions?

Feel free to send feature requests or merge request to the author or simply to ask questions.


All versions of uploader with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/http Version ^11.0
danielstjules/stringy Version ^3.1
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 seblhaire/uploader contains the following files

Loading the files please wait ....