PHP code example of twom / laravel-file-manger

1. Go to this page and download the library: Download twom/laravel-file-manger 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/ */

    

twom / laravel-file-manger example snippets


$file = request()->file('filename');
$upload = File::upload($file);

//	get file uploaded path
$filePath = $upload->getFilePath();

//	get file name  
$fileName = $upload->getName();

$file = request()->file('filename');  
$upload = \Twom\FileManager\Facades\File::setName('your specific name')  
	 ->isPrivate()  
	 ->setFormat('png')  
	 ->dateTimePrefix()  
	 ->upload($file);
//	get file uploaded path => if is public you can use it for download
dd($upload->getFilePath());

$file = File::getFile("file uploaded name");  
$file->name;  
$file->path;  
$file->type; // config file selected type  
$file->isPrivate;  
$file->isPublic;  
$file->generateLink();  
  
// return response download  
// $file->download();

$file = request()->file('filename');  
$upload = \Twom\FileManager\Facades\File::type("type_name") // type name in config file (filemanager.php)
    ->upload($file);
 php
'providers' => [
	 // for laravel 5.8 and below
	 \Twom\FileManager\FileManagerServiceProvider::class,
];

php artisan vendor:publish
 php
return [  
  "type" => "default",  
  
  "types" => [  
	  "default" => [  
		  "provider" => \Twom\FileManager\Types\File::class,  
		  "path" => "default_files/test/",  
		  "private" => false,  
		  "date_time_prefix" => true,  
		  "use_file_name_to_upload" => false,  
		  "secret" => "ashkdsjka#sdkdjfsj22188455$$#$%dsDFsdf",  
		  "download_link_expire" => 160, // minutes  
	  ],
      "image"   => [
          "provider" => \Twom\FileManager\Types\Image::class,
          "path"     => "images/upload/documents/",
          "sizes"    => ["16", "24", "32", "64", "128", "320"],
          "thumb"    => "320"
      ],
      "profile" => [
          "parent"           => "image",
          "path"             => "images/upload/profiles/",
          "date_time_prefix" => false,
      ],  
  ],  
];