PHP code example of samankhdev / lara-file

1. Go to this page and download the library: Download samankhdev/lara-file library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

samankhdev / lara-file example snippets


    $laraFile = new LaraUpload();
    $laraFile->push($request->img, "products/img");
    $laraFile->send();

    $laraFile = new LaraUpload();
    $laraFile->pushMany([
            [
                'dir'=>'images',
                'file'=>$request->file,
                'disk'=>'privateImages' //default is `public`
            ],...
    ]);
        $laraFile->send();

    $files = [];
    foreach ($request->file as $file) {
        array_push($files, [
            "file" => $file
        ]);
    }

    $lara = new LaraUpload($files);
    $lara->send();

    $files = [];
    foreach ($request->file as $file) {
        array_push($files, [
            'dir'=>'images',
            "file" => $file
        ]);
    }

    $lara = new LaraUpload($files);
    $lara->send();

    $files = [];
    foreach ($request->file as $file) {
        array_push($files, [
            'dir'=>'images',
            'disk'=>'PrivateFiles',
            "file" => $file
        ]);
    }

    $lara = new LaraUpload($files);
    $lara->send();