PHP code example of coding-socks / laravel-upload-handler

1. Go to this page and download the library: Download coding-socks/laravel-upload-handler 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/ */

    

coding-socks / laravel-upload-handler example snippets


Route::any('/my-route', 'MyController@myFunction');

use Illuminate\Http\Request;
use CodingSocks\UploadHandler\UploadHandler;

class MyController extends Controller
{
    public function myFunction(Request $request, UploadHandler $handler)
    {
        return $handler->handle($request);
    }
}

use Illuminate\Http\Request;
use CodingSocks\UploadHandler\UploadHandler;

class MyController extends Controller
{
    public function myFunction(Request $request)
    {
        $handler = app()->make(UploadHandler::class);
        return $handler->handle($request);
    }
}

$handler->handle($request, function ($disk, $path) {
    // Triggered when upload is finished
});

app()->make(UploadManager::class)->extend('my_driver', function () {
    return new MyCustomUploadDriver();
});