PHP code example of anomaly / files-module

1. Go to this page and download the library: Download anomaly/files-module 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/ */

    

anomaly / files-module example snippets


use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;

$files = app(FileRepositoryInterface::class);

// Upload from request
$file = $files->upload(request()->file('upload'), $folder);

// Create from path
$file = $files->create([
    'name' => 'document.pdf',
    'folder_id' => $folderId,
    'disk_id' => $diskId,
    'path' => 'path/to/file.pdf'
]);

// Get file by ID
$file = $files->find(1);

// Get file URL
$url = $file->path();

// Get thumbnail
$thumb = $file->thumbnail('small');

// Get image dimensions
$width = $file->width;
$height = $file->height;