This commit is contained in:
splin94@yandex.ru 2023-11-10 07:24:04 +00:00
parent 35fa74ee8a
commit a313353a54
33 changed files with 1905 additions and 301 deletions

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UploadFiles extends Controller
{
public function upload(Request $request)
{
$path = $request->file('avatar')->store('avatars');
return $path;
}
}

View File

@ -8,7 +8,8 @@
],
"license": "MIT",
"require": {
"php": "^7.3|^8.2",
"php": "^7.3|^8.1",
"erlandmuchasaj/laravel-file-uploader": "^1.0",
"faisal50x/query-filter": "^1.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",

91
code/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b6b30841da551def9c23599f31146e84",
"content-hash": "98fb3f9a3aaf4e4d715a79ecc82144eb",
"packages": [
{
"name": "asm89/stack-cors",
@ -488,6 +488,91 @@
],
"time": "2020-12-29T14:50:06+00:00"
},
{
"name": "erlandmuchasaj/laravel-file-uploader",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/erlandmuchasaj/laravel-file-uploader.git",
"reference": "9841bb092c381996cb5880a0f7d2abaaaaed1816"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erlandmuchasaj/laravel-file-uploader/zipball/9841bb092c381996cb5880a0f7d2abaaaaed1816",
"reference": "9841bb092c381996cb5880a0f7d2abaaaaed1816",
"shasum": ""
},
"require": {
"ext-exif": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"illuminate/contracts": "^8|^9|^10",
"illuminate/filesystem": "^8|^9|^10",
"illuminate/http": "^8|^9|^10",
"illuminate/support": "^8|^9|^10",
"nesbot/carbon": "^2",
"php": "^8.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"ErlandMuchasaj\\LaravelFileUploader\\FileUploaderServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"ErlandMuchasaj\\LaravelFileUploader\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Erland Muchasaj",
"email": "erland.muchasaj@gmail.com",
"homepage": "https://erlandmuchasaj.tech/",
"role": "Developer"
}
],
"description": "A simple package to help you easily upload files to your laravel project.",
"homepage": "https://github.com/erlandmuchasaj/laravel-file-uploader",
"keywords": [
"cms",
"emcms",
"file",
"images",
"laravel",
"library",
"media",
"package",
"upload"
],
"support": {
"email": "erland.muchasaj@gmail.com",
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/erlandmuchasaj/laravel-file-uploader/issues",
"source": "https://github.com/erlandmuchasaj/laravel-file-uploader"
},
"funding": [
{
"url": "https://ko-fi.com/erlandmuchasaj",
"type": "Ko-fi"
},
{
"url": "https://paypal.me/emcms?country.x=AL&locale.x=en_US",
"type": "PayPal"
},
{
"url": "https://www.patreon.com/erlandmuchasaj",
"type": "patreon"
}
],
"time": "2023-07-11T09:35:24+00:00"
},
{
"name": "faisal50x/query-filter",
"version": "v1.0.6",
@ -8966,8 +9051,8 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.3|^8.2"
"php": "^7.3|^8.1"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.2.0"
}

View File

@ -15,7 +15,7 @@ return [
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------

View File

@ -1,7 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use ErlandMuchasaj\LaravelFileUploader\FileUploader; // <= import the package
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
@ -13,6 +14,29 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::post('/upload', function (Request $request) {
echo 123;exit;
$max_size = (int) ini_get('upload_max_filesize') * 1000;
$extensions = implode(',', FileUploader::images());
$request->validate([
'file' => [
'required',
'file',
'image',
'mimes:' . $extensions,
'max:'.$max_size,
]
]);
$file = $request->file('file');
//$response = FileUploader::store($file);
return redirect()
->back()
->with('success','File has been uploaded.')
->with('file', $response);
})->name('files.store');

2
code/storage/debugbar/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -2,24 +2,6 @@
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInite02496dcc909b631cc2eec0f86cb5cfc::getLoader();

View File

@ -42,37 +42,35 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
@ -80,7 +78,8 @@ class ClassLoader
private $useIncludePath = false;
/**
* @var array<string, string>
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
@ -88,29 +87,29 @@ class ClassLoader
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
/** @var ?string */
private $apcuPrefix;
/**
* @var array<string, self>
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
* @return string[]
*/
public function getPrefixes()
{
@ -122,7 +121,8 @@ class ClassLoader
}
/**
* @return array<string, list<string>>
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
@ -130,7 +130,8 @@ class ClassLoader
}
/**
* @return list<string>
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
@ -138,7 +139,8 @@ class ClassLoader
}
/**
* @return list<string>
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
@ -146,7 +148,8 @@ class ClassLoader
}
/**
* @return array<string, string> Array of classname => path
* @return string[] Array of classname => path
* @psalm-return array<string, string>
*/
public function getClassMap()
{
@ -154,7 +157,8 @@ class ClassLoader
}
/**
* @param array<string, string> $classMap Class to filename map
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
@ -172,24 +176,23 @@ class ClassLoader
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
(array) $paths
);
}
@ -198,19 +201,19 @@ class ClassLoader
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
(array) $paths
);
}
}
@ -220,7 +223,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
@ -229,18 +232,17 @@ class ClassLoader
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@ -250,18 +252,18 @@ class ClassLoader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
(array) $paths
);
}
}
@ -271,7 +273,7 @@ class ClassLoader
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
@ -289,7 +291,7 @@ class ClassLoader
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
@ -423,8 +425,7 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
includeFile($file);
return true;
}
@ -475,9 +476,9 @@ class ClassLoader
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return array<string, self>
* @return self[]
*/
public static function getRegisteredLoaders()
{
@ -554,14 +555,6 @@ class ClassLoader
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
@ -571,9 +564,9 @@ class ClassLoader
*
* @param string $file
* @return void
* @private
*/
self::$includeFile = \Closure::bind(static function($file) {
function includeFile($file)
{
include $file;
}, null, null);
}
}

View File

@ -21,14 +21,12 @@ use Composer\Semver\VersionParser;
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
*/
private static $installed;
@ -39,7 +37,7 @@ class InstalledVersions
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static $installedByVendor = array();
@ -98,7 +96,7 @@ class InstalledVersions
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
}
}
@ -119,7 +117,7 @@ class InstalledVersions
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints((string) $constraint);
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
@ -243,7 +241,7 @@ class InstalledVersions
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
*/
public static function getRootPackage()
{
@ -257,7 +255,7 @@ class InstalledVersions
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
*/
public static function getRawData()
{
@ -280,7 +278,7 @@ class InstalledVersions
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
public static function getAllRawData()
{
@ -303,7 +301,7 @@ class InstalledVersions
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
*/
public static function reload($data)
{
@ -313,7 +311,7 @@ class InstalledVersions
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static function getInstalled()
{
@ -328,9 +326,7 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
@ -342,17 +338,12 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}

View File

@ -1,4 +1,3 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -2,13 +2,14 @@
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\UploadFiles' => $baseDir . '/app/Http/Controllers/UploadFiles.php',
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => $baseDir . '/app/Http/Middleware/Authenticate.php',
'App\\Http\\Middleware\\EncryptCookies' => $baseDir . '/app/Http/Middleware/EncryptCookies.php',
@ -818,6 +819,12 @@ return array(
'Egulias\\EmailValidator\\Warning\\QuotedString' => $vendorDir . '/egulias/email-validator/src/Warning/QuotedString.php',
'Egulias\\EmailValidator\\Warning\\TLD' => $vendorDir . '/egulias/email-validator/src/Warning/TLD.php',
'Egulias\\EmailValidator\\Warning\\Warning' => $vendorDir . '/egulias/email-validator/src/Warning/Warning.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\InvalidFile' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/InvalidFile.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\InvalidUpload' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/InvalidUpload.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\MissingFile' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/MissingFile.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\UploadFailed' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/UploadFailed.php',
'ErlandMuchasaj\\LaravelFileUploader\\FileUploader' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/FileUploader.php',
'ErlandMuchasaj\\LaravelFileUploader\\FileUploaderServiceProvider' => $vendorDir . '/erlandmuchasaj/laravel-file-uploader/src/FileUploaderServiceProvider.php',
'Facade\\FlareClient\\Api' => $vendorDir . '/facade/flare-client-php/src/Api.php',
'Facade\\FlareClient\\Concerns\\HasContext' => $vendorDir . '/facade/flare-client-php/src/Concerns/HasContext.php',
'Facade\\FlareClient\\Concerns\\UsesTime' => $vendorDir . '/facade/flare-client-php/src/Concerns/UsesTime.php',

View File

@ -2,39 +2,39 @@
// autoload_files.php @generated by Composer
$vendorDir = dirname(__DIR__);
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php',
'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php',
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
'538ca81a9a966a6716601ecf48f4eaef' => $vendorDir . '/opis/closure/functions.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'c72349b1fe8d0deeedd3a52e8aa814d8' => $vendorDir . '/mockery/mockery/library/helpers.php',
'ce9671a430e4846b44e1c68c7611f9f5' => $vendorDir . '/mockery/mockery/library/Mockery.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'9cdd7b9056abc3081735233ba9dd9c7f' => $vendorDir . '/facade/flare-client-php/src/helpers.php',
'538ca81a9a966a6716601ecf48f4eaef' => $vendorDir . '/opis/closure/functions.php',
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
'265b4faa2b3a9766332744949e83bf97' => $vendorDir . '/laravel/framework/src/Illuminate/Collections/helpers.php',
'c7a3c339e7e14b60e06a2d7fcce9476b' => $vendorDir . '/laravel/framework/src/Illuminate/Events/functions.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'9cdd7b9056abc3081735233ba9dd9c7f' => $vendorDir . '/facade/flare-client-php/src/helpers.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'801c31d8ed748cfa537fa45402288c95' => $vendorDir . '/psy/psysh/src/functions.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'4a1f389d6ce373bda9e57857d3b61c84' => $vendorDir . '/barryvdh/laravel-debugbar/src/helpers.php',
'ed962a97bd972bc82007176b647d4e36' => $vendorDir . '/facade/ignition/src/helpers.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'c72349b1fe8d0deeedd3a52e8aa814d8' => $vendorDir . '/mockery/mockery/library/helpers.php',
'ce9671a430e4846b44e1c68c7611f9f5' => $vendorDir . '/mockery/mockery/library/Mockery.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
'377b22b161c09ed6e5152de788ca020a' => $vendorDir . '/spatie/laravel-permission/src/helpers.php',
);

View File

@ -2,7 +2,7 @@
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(

View File

@ -2,7 +2,7 @@
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
@ -79,6 +79,7 @@ return array(
'Facade\\Ignition\\' => array($vendorDir . '/facade/ignition/src'),
'Facade\\IgnitionContracts\\' => array($vendorDir . '/facade/ignition-contracts/src'),
'Facade\\FlareClient\\' => array($vendorDir . '/facade/flare-client-php/src'),
'ErlandMuchasaj\\LaravelFileUploader\\' => array($vendorDir . '/erlandmuchasaj/laravel-file-uploader/src'),
'Egulias\\EmailValidator\\' => array($vendorDir . '/egulias/email-validator/src'),
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),

View File

@ -25,26 +25,56 @@ class ComposerAutoloaderInite02496dcc909b631cc2eec0f86cb5cfc
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInite02496dcc909b631cc2eec0f86cb5cfc', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInite02496dcc909b631cc2eec0f86cb5cfc', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiree02496dcc909b631cc2eec0f86cb5cfc($fileIdentifier, $file);
}
return $loader;
}
}
/**
* @param string $fileIdentifier
* @param string $file
* @return void
*/
function composerRequiree02496dcc909b631cc2eec0f86cb5cfc($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}

View File

@ -7,36 +7,36 @@ namespace Composer\Autoload;
class ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php',
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
'538ca81a9a966a6716601ecf48f4eaef' => __DIR__ . '/..' . '/opis/closure/functions.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'c72349b1fe8d0deeedd3a52e8aa814d8' => __DIR__ . '/..' . '/mockery/mockery/library/helpers.php',
'ce9671a430e4846b44e1c68c7611f9f5' => __DIR__ . '/..' . '/mockery/mockery/library/Mockery.php',
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php',
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
'9cdd7b9056abc3081735233ba9dd9c7f' => __DIR__ . '/..' . '/facade/flare-client-php/src/helpers.php',
'538ca81a9a966a6716601ecf48f4eaef' => __DIR__ . '/..' . '/opis/closure/functions.php',
'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php',
'265b4faa2b3a9766332744949e83bf97' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Collections/helpers.php',
'c7a3c339e7e14b60e06a2d7fcce9476b' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Events/functions.php',
'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'9cdd7b9056abc3081735233ba9dd9c7f' => __DIR__ . '/..' . '/facade/flare-client-php/src/helpers.php',
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'801c31d8ed748cfa537fa45402288c95' => __DIR__ . '/..' . '/psy/psysh/src/functions.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
'4a1f389d6ce373bda9e57857d3b61c84' => __DIR__ . '/..' . '/barryvdh/laravel-debugbar/src/helpers.php',
'ed962a97bd972bc82007176b647d4e36' => __DIR__ . '/..' . '/facade/ignition/src/helpers.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'c72349b1fe8d0deeedd3a52e8aa814d8' => __DIR__ . '/..' . '/mockery/mockery/library/helpers.php',
'ce9671a430e4846b44e1c68c7611f9f5' => __DIR__ . '/..' . '/mockery/mockery/library/Mockery.php',
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
'377b22b161c09ed6e5152de788ca020a' => __DIR__ . '/..' . '/spatie/laravel-permission/src/helpers.php',
);
@ -158,6 +158,7 @@ class ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc
),
'E' =>
array (
'ErlandMuchasaj\\LaravelFileUploader\\' => 35,
'Egulias\\EmailValidator\\' => 23,
),
'D' =>
@ -492,6 +493,10 @@ class ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc
array (
0 => __DIR__ . '/..' . '/facade/flare-client-php/src',
),
'ErlandMuchasaj\\LaravelFileUploader\\' =>
array (
0 => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src',
),
'Egulias\\EmailValidator\\' =>
array (
0 => __DIR__ . '/..' . '/egulias/email-validator/src',
@ -600,6 +605,7 @@ class ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\UploadFiles' => __DIR__ . '/../..' . '/app/Http/Controllers/UploadFiles.php',
'App\\Http\\Kernel' => __DIR__ . '/../..' . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => __DIR__ . '/../..' . '/app/Http/Middleware/Authenticate.php',
'App\\Http\\Middleware\\EncryptCookies' => __DIR__ . '/../..' . '/app/Http/Middleware/EncryptCookies.php',
@ -1409,6 +1415,12 @@ class ComposerStaticInite02496dcc909b631cc2eec0f86cb5cfc
'Egulias\\EmailValidator\\Warning\\QuotedString' => __DIR__ . '/..' . '/egulias/email-validator/src/Warning/QuotedString.php',
'Egulias\\EmailValidator\\Warning\\TLD' => __DIR__ . '/..' . '/egulias/email-validator/src/Warning/TLD.php',
'Egulias\\EmailValidator\\Warning\\Warning' => __DIR__ . '/..' . '/egulias/email-validator/src/Warning/Warning.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\InvalidFile' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/InvalidFile.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\InvalidUpload' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/InvalidUpload.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\MissingFile' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/MissingFile.php',
'ErlandMuchasaj\\LaravelFileUploader\\Exceptions\\UploadFailed' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/Exceptions/UploadFailed.php',
'ErlandMuchasaj\\LaravelFileUploader\\FileUploader' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/FileUploader.php',
'ErlandMuchasaj\\LaravelFileUploader\\FileUploaderServiceProvider' => __DIR__ . '/..' . '/erlandmuchasaj/laravel-file-uploader/src/FileUploaderServiceProvider.php',
'Facade\\FlareClient\\Api' => __DIR__ . '/..' . '/facade/flare-client-php/src/Api.php',
'Facade\\FlareClient\\Concerns\\HasContext' => __DIR__ . '/..' . '/facade/flare-client-php/src/Concerns/HasContext.php',
'Facade\\FlareClient\\Concerns\\UsesTime' => __DIR__ . '/..' . '/facade/flare-client-php/src/Concerns/UsesTime.php',

View File

@ -1321,6 +1321,94 @@
],
"install-path": "../egulias/email-validator"
},
{
"name": "erlandmuchasaj/laravel-file-uploader",
"version": "1.0.5",
"version_normalized": "1.0.5.0",
"source": {
"type": "git",
"url": "https://github.com/erlandmuchasaj/laravel-file-uploader.git",
"reference": "9841bb092c381996cb5880a0f7d2abaaaaed1816"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erlandmuchasaj/laravel-file-uploader/zipball/9841bb092c381996cb5880a0f7d2abaaaaed1816",
"reference": "9841bb092c381996cb5880a0f7d2abaaaaed1816",
"shasum": ""
},
"require": {
"ext-exif": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"illuminate/contracts": "^8|^9|^10",
"illuminate/filesystem": "^8|^9|^10",
"illuminate/http": "^8|^9|^10",
"illuminate/support": "^8|^9|^10",
"nesbot/carbon": "^2",
"php": "^8.0"
},
"time": "2023-07-11T09:35:24+00:00",
"type": "library",
"extra": {
"laravel": {
"providers": [
"ErlandMuchasaj\\LaravelFileUploader\\FileUploaderServiceProvider"
]
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"ErlandMuchasaj\\LaravelFileUploader\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Erland Muchasaj",
"email": "erland.muchasaj@gmail.com",
"homepage": "https://erlandmuchasaj.tech/",
"role": "Developer"
}
],
"description": "A simple package to help you easily upload files to your laravel project.",
"homepage": "https://github.com/erlandmuchasaj/laravel-file-uploader",
"keywords": [
"cms",
"emcms",
"file",
"images",
"laravel",
"library",
"media",
"package",
"upload"
],
"support": {
"email": "erland.muchasaj@gmail.com",
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/erlandmuchasaj/laravel-file-uploader/issues",
"source": "https://github.com/erlandmuchasaj/laravel-file-uploader"
},
"funding": [
{
"url": "https://ko-fi.com/erlandmuchasaj",
"type": "Ko-fi"
},
{
"url": "https://paypal.me/emcms?country.x=AL&locale.x=en_US",
"type": "PayPal"
},
{
"url": "https://www.patreon.com/erlandmuchasaj",
"type": "patreon"
}
],
"install-path": "../erlandmuchasaj/laravel-file-uploader"
},
{
"name": "facade/flare-client-php",
"version": "1.10.0",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
/vendor
composer.lock
.DS_Store
.idea

View File

@ -0,0 +1,7 @@
# Changelog
All notable changes to `erlandmuchasaj/laravel-file-uploader` will be documented in this file.
## 1.0.0 - 2023-03-06
- initial release

View File

@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
dave@blakey.co.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@ -0,0 +1,56 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skills, strengths, and weaknesses.
Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Requirements
If the project maintainer has any additional requirements, you will find them listed here.
- **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Erland Muchasaj <erland.muchasaj@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,156 @@
# Laravel File Uploader
Laravel File Uploader offers an easy way to upload files to different disks.
The main purpose of the package is to remove the repeated and cumbersome code and simplify it into some simple methods.
## Installation
You can install the package via composer:
```bash
composer require erlandmuchasaj/laravel-file-uploader
```
## Usage
This package has an very easy and straight-forward usage.
Just import the package and pass the file as parameter, and it will handle the rest.
```php
use ErlandMuchasaj\LaravelFileUploader\FileUploader;
Route::post('/files', function (\Illuminate\Http\Request $request) {
$max_size = (int) ini_get('upload_max_filesize') * 1000;
// FileUploader::images() get all image extensions ex: jpg, png, jpeg, gif, etc.
// FileUploader::documents() get all documents extensions ex: 'csv', 'html', 'pdf', 'doc', 'docx', 'ppt' etc.
$extensions = implode(',', FileUploader::images());
$request->validate([
'file' => [
'required',
'file',
'image',
'mimes:' . $extensions,
'max:'.$max_size,
]
]);
$file = $request->file('file');
$response = FileUploader::store($file);
// $response = FileUploader::store($file, $options);
// available options (as key=>value pare) are:
// `disk`, 'user_id`, `path`, `visibility`
// do something with the $response
// you can save it into your model etc.
return redirect()
->back()
->with('success', __('File has been uploaded.'))
->with('file', $response);
})->name('files.store');
/**
* $response = [
* "type" => "image"
* "extension" => "png"
* "_extension" => "png"
* "name" => "blog3"
* "original_name" => "blog3.png"
* "size" => 549247
* "mime_type" => "image/png"
* "dimensions" => "670x841"
* "path" => "uploads/1/image/blog3_1678118034.png" // <==
* "url" => "/storage/uploads/1/image/blog3_1678118034.png"
* "user_id" => 1
* "disk" => "local"
* "visibility" => "public"
* "uuid" => "dd5889c0-5057-49ef-a6ef-e3da961a47d1"
* ]
*/
```
If you need to modify the config files, you should publish the migration and the config/permission.php config file
with:
```bash
php artisan vendor:publish --provider="ErlandMuchasaj\LaravelFileUploader\FileUploaderServiceProvider"
```
Some other helper methods:
```php
$path = 'uploads/1/image/blog3_1678118034.png'; // the path of the image where is stored.
$response = FileUploader::get($path); // get file as StreamedResponse
$response = FileUploader::getFile($path); // get file as content.
$response = FileUploader::url($path); // full path url - /storage/uploads/1/image/blog3_1678118034.png
$response = FileUploader::path($path); // C:\wamp\www\laravel-app\storage\app\uploads/1/image/blog3_1678118034.png
$response = FileUploader::meta($path); // metadata about the file.
/**
* [
* "path" => "C:\wamp\www\laravel-app\storage\app\uploads/1/image/blog3_1678118034.png"
* "url" => "/storage/uploads/1/image/blog3_1678118034.png"
* "visibility" => "public"
* "mimeType" => "image/png"
* "size" => "536.37 KB"
* "last_modified" => "1 hour ago"
* "name" => "blog3_1678118034.png"
* "pathinfo" => [
* "dirname" => "uploads/1/image"
* "basename" => "blog3_1678118034.png"
* "extension" => "png"
* "filename" => "blog3_1678118034"
* ]
* ]
*/
$response = FileUploader::download($path, 'something_nice'); // download the file as StreamedResponse
$response = FileUploader::getVisibility($path); // file visibility when applicable private/public
$response = FileUploader::setVisibility($path, 'private'); // change file visibility
$response = FileUploader::remove($path); // delete a file
```
Also, some other size converting helper functions are available for example:
```php
$size = 549247;
FileUploader::formatBytes($size); // "536.37 KB"
FileUploader::convertBytesToSpecified($size, 'KB'); // 536.37KB
FileUploader::convertBytesToSpecified($size, 'MB'); // 0.52MB
```
---
## Support me
I invest a lot of time and resources into creating [best in class open source packages](https://github.com/erlandmuchasaj?tab=repositories).
If you found this package helpful you can show support by clicking on the following button below and donating some amount to help me work on these projects frequently.
<a href="https://www.buymeacoffee.com/erland" target="_blank">
<img src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-2.svg" style="height: 45px; border-radius: 12px" alt="buy me a coffee"/>
</a>
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please see [SECURITY](SECURITY.md) for details.
## Credits
- [Erland Muchasaj](https://github.com/erlandmuchasaj)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

View File

@ -0,0 +1,13 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
## Reporting a Vulnerability
If you discover a security vulnerability within this package,
please send an e-mail to Erland Muchasaj via [erland.muchasaj@gmail.com](mailto:erland.muchasaj@gmail.com).
All security vulnerabilities will be promptly addressed.

View File

@ -0,0 +1,76 @@
{
"name": "erlandmuchasaj/laravel-file-uploader",
"type": "library",
"description": "A simple package to help you easily upload files to your laravel project.",
"minimum-stability": "dev",
"prefer-stable": true,
"homepage": "https://github.com/erlandmuchasaj/laravel-file-uploader",
"license": "MIT",
"keywords": [
"file",
"media",
"images",
"upload",
"laravel",
"library",
"cms",
"emcms",
"package"
],
"autoload": {
"psr-4": {
"ErlandMuchasaj\\LaravelFileUploader\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"ErlandMuchasaj\\LaravelFileUploader\\FileUploaderServiceProvider"
]
}
},
"authors": [
{
"name": "Erland Muchasaj",
"email": "erland.muchasaj@gmail.com",
"homepage": "https://erlandmuchasaj.tech/",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/erlandmuchasaj/laravel-file-uploader/issues",
"source": "https://github.com/erlandmuchasaj/laravel-file-uploader",
"email": "erland.muchasaj@gmail.com",
"irc": "irc://irc.freenode.org/composer"
},
"funding": [
{
"type": "patreon",
"url": "https://www.patreon.com/erlandmuchasaj"
},
{
"type": "Ko-fi",
"url": "https://ko-fi.com/erlandmuchasaj"
},
{
"type": "PayPal",
"url": "https://paypal.me/emcms?country.x=AL&locale.x=en_US"
}
],
"config": {
"sort-packages": true,
"preferred-install": "dist",
"optimize-autoloader": true
},
"require": {
"php": "^8.0",
"ext-exif": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"nesbot/carbon": "^2",
"illuminate/http": "^8|^9|^10",
"illuminate/support": "^8|^9|^10",
"illuminate/contracts": "^8|^9|^10",
"illuminate/filesystem": "^8|^9|^10"
}
}

View File

@ -0,0 +1,55 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the package.
|
*/
'disk' => env('FILESYSTEM_DISK', 'local'),
'visibility' => 'public',
/*
|--------------------------------------------------------------------------
| Filesystem path
|--------------------------------------------------------------------------
|
| Here you may configure the path structure of the uploaded files
| uploads/{user_id}/{type}/{filename}
|
| Supported variables: "{user_id}", "{type}", "{filename}"
|
*/
'path' => 'uploads/{user_id}/{type}/{filename}',
/*
|--------------------------------------------------------------------------
| Default files user group
|--------------------------------------------------------------------------
|
| All files will be grouped by default to root user aka ID=1.
| If you have a different default user id you can set it here.
|
*/
'user_id' => 1,
/*
|--------------------------------------------------------------------------
| Shall we use safe extension and name extraction
|--------------------------------------------------------------------------
|
| getClientOriginalName() and getClientOriginalExtension()
| are considered unsafe.
|
*/
'safe' => false,
];

View File

@ -0,0 +1,9 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader\Exceptions;
use Exception;
class InvalidFile extends Exception
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader\Exceptions;
use Exception;
class InvalidUpload extends Exception
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader\Exceptions;
use Exception;
class MissingFile extends Exception
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader\Exceptions;
use Exception;
class UploadFailed extends Exception
{
}

View File

@ -0,0 +1,770 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader;
use Carbon\Carbon;
use ErlandMuchasaj\LaravelFileUploader\Exceptions\InvalidFile;
use ErlandMuchasaj\LaravelFileUploader\Exceptions\InvalidUpload;
use ErlandMuchasaj\LaravelFileUploader\Exceptions\MissingFile;
use ErlandMuchasaj\LaravelFileUploader\Exceptions\UploadFailed;
use Exception;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use League\Flysystem\WhitespacePathNormalizer;
use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
use Symfony\Component\HttpFoundation\StreamedResponse;
final class FileUploader
{
/**
* Default file storage disk where files are stored
*/
private static string $disk = 'public';
/**
* The cache of this.
*
* @var array<string, string>
*/
protected static array $studlyCache = [];
/**
* default constants used to build file path
*/
const UPLOAD_PATH = 'uploads/{user_id}/{type}/{filename}';
/**
* The public visibility setting.
* - default
*
* @var string
*/
const VISIBILITY_PUBLIC = 'public';
/**
* The private visibility setting.
*
* @var string
*/
const VISIBILITY_PRIVATE = 'private';
/**
* Available file folder for sizes
*/
const ORIGINAL = 'original'; // this is not a directory just used as name
const THUMB = 'thumb';
const XSMALL = 'xs';
const SMALL = 'sm';
const MEDIUM = 'md';
const LARGE = 'lg';
const XLARGE = 'xl';
/**
* Available file types
* suppoerted by fileService
*/
const IMAGE = 'image';
const AUDIO = 'audio';
const VIDEO = 'video';
const FILE = 'file';
const FONT = 'font';
const ARCHIVE = 'archive';
const DOCUMENT = 'document';
const SPREADSHEETS = 'spreadsheets';
/**
* Available file types
*
* @var array<int, string>
*/
public static array $validTypes = [
self::IMAGE,
self::AUDIO,
self::VIDEO,
self::FILE,
self::FONT,
self::ARCHIVE,
self::DOCUMENT,
self::SPREADSHEETS,
];
/**
* Available sizes for images
*
* @var array<string, int>
*/
public static array $validSizes = [
self::THUMB => 60,
self::XSMALL => 150,
self::SMALL => 300,
self::MEDIUM => 768,
self::LARGE => 1024,
self::XLARGE => 2048,
];
/**
* validOptions of visibility
*
* @var array<int, string>
*/
public static array $validOptions = [
self::VISIBILITY_PUBLIC,
self::VISIBILITY_PRIVATE,
];
/**
* $image_ext
*
* @var array<int, string>
*/
private static array $image_ext = ['jpg', 'pjpg', 'jpe', 'jpeg', 'png', 'bmp', 'gif', 'svg', 'svgz', 'tiff', 'tif', 'webp', 'ico', 'avif'];
/**
* $font_ext
*
* @var array<int, string>
*/
private static array $font_ext = ['ttc', 'otf', 'ttf', 'woff', 'woff2'];
/**
* $audio_ext
*
* @var array<int, string>
*/
private static array $audio_ext = ['mp3', 'm4a', 'ogg', 'mpga', 'wav'];
/**
* $video_ext
*
* @var array<int, string>
*/
private static array $video_ext = ['smv', 'movie', 'mov', 'wvx', 'wmx', 'wm', 'mp4', 'mp4', 'mp4v', 'mpg4', 'mpeg', 'mpg', 'mpe', 'wmv', 'avi', 'ogv', '3gp', '3g2'];
/**
* $document_ext
*
* @var array<int, string>
*/
private static array $document_ext = ['css', 'csv', 'html', 'htm', 'conf', 'log', 'txt', 'text', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'odt', 'xls', 'xlsx'];
/**
* $archive
*
* @var array<int, string>
*
* @example application/zip
*/
private static array $archives_ext = ['gzip', 'rar', 'tar', 'zip', '7z'];
/**
* Upload a file into specified disk using
* specified visibility and then store into DB.
*
* @param array<string, string> $args
* @return array<string, mixed>
*
* @throws UploadFailed
*/
public static function store(
UploadedFile $file,
array $args = []
): array {
try {
$data = self::upload($file, $args);
} catch (Exception $e) {
throw new UploadFailed($e->getMessage(), $e->getCode());
}
return $data;
}
/**
* Upload an image to specific FileSystem
*
* @param array<string, string> $options
* @return array<string, mixed>
*
* @throws InvalidUpload
* @throws InvalidFile
*/
public static function upload(UploadedFile $file, array $options = []): array
{
if (! $file->isValid()) {
throw new InvalidFile($file->getErrorMessage());
}
if ($file->getSize() === false) {
throw new InvalidFile('File failed to load.');
}
// // here you can put as many default values as you want.
// $defaults = [
// 'disk' => self::$disk, // The disk where the file is being saved.
// 'safe' => false, // weather or not to use safe client file operators
// 'user_id' => 1, // files are grouped by user.
// 'path' => self::UPLOAD_PATH, // Where files are being stored.
// 'visibility' => self::VISIBILITY_PUBLIC, // public | private
// ];
$defaults = self::getConfig();
// merge default options with passed parameters
$args = array_merge($defaults, $options);
if (! in_array($args['visibility'], self::$validOptions, true)) {
$args['visibility'] = self::VISIBILITY_PUBLIC;
}
$disk = $args['disk'] ?? self::$disk;
$user_id = $args['user_id'] ?? null;
/**
* getClientOriginalName() and getClientOriginalExtension() are considered
* unsafe therefor we use hashName() and extension()
*/
// get filename with extension
$filenameWithExtension = $file->getClientOriginalName();
// $filenameWithExtension = $file->hashName() ?: $file->getClientOriginalName();
// get file extension
$extension = $file->getClientOriginalExtension();
// $extension = $file->extension() ?: $file->getClientOriginalExtension();
// get filename without extension
$filename = pathinfo($filenameWithExtension, PATHINFO_FILENAME);
// @todo - EM: Check filename normalizer
$filename = (new WhitespacePathNormalizer)->normalizePath($filename);
$filename = self::defaultSanitizer($filename);
// filename to store
$filenameToStore = $filename.'_'.time().'.'.$extension;
// Get the type of file we are storing
$type = self::getType($extension);
// Make a file path where image will be stored [uploads/{user_id}/{type}/{filename}.{ext}]
$filePath = self::getUserDir($filenameToStore, $type, (int) $user_id);
// Upload File to storage disk
$fileContent = fopen($file, 'r+');
if (! $fileContent) {
throw new InvalidUpload('Could not read file from disk...');
}
$path = Storage::disk($disk)->put($filePath, $fileContent, $args['visibility']); // very nice for very big files
// Store $filePath in the database
if (! $path) {
throw new InvalidUpload('The file could not be written to disk...');
}
// dd([
// 'type' => $type,
// 'extension' => $file->getClientOriginalExtension(),
// '_extension' => $file->extension() ?: $file->getClientOriginalExtension(),
// 'name' => $filename,
// 'original_name' => $file->getClientOriginalName(),
// 'size' => $file->getSize(),
// 'mime_type' => $file->getClientMimeType(),
// 'dimensions' => self::getDimensions($file, $type),
// 'path' => $filePath,
// 'url' => Storage::disk($disk)->url($filePath),
// 'user_id' => $user_id,
// 'disk' => $disk,
// 'visibility' => $args['visibility'], // indicate if file is public or private
// 'hash_file' => self::getHashFile($file),
// 'uuid' => Str::uuid()->toString(),
// ]);
return [
'type' => $type,
'extension' => $file->getClientOriginalExtension(),
'_extension' => $file->extension() ?: $file->getClientOriginalExtension(),
'name' => $filename,
'original_name' => $file->getClientOriginalName(),
'size' => $file->getSize(),
'mime_type' => $file->getClientMimeType(),
'dimensions' => self::getDimensions($file, $type),
'path' => $filePath,
'url' => Storage::disk($disk)->url($filePath),
'user_id' => $user_id,
'disk' => $disk,
'visibility' => $args['visibility'], // indicate if file is public or private
'uuid' => Str::uuid()->toString(),
];
}
protected static function getUser(int $user_id = null): ?int
{
$defaults = self::getConfig();
return $user_id ?? (! empty($defaults['user_id']) ? (int) $defaults['user_id'] : 1);
}
protected static function getDisk(string $disk = null): string
{
$key = $disk;
if (isset(FileUploader::$studlyCache['disk_'.$key])) {
return FileUploader::$studlyCache['disk_'.$key];
}
$defaults = self::getConfig();
return FileUploader::$studlyCache['disk_'.$key] = $disk ?: $defaults['disk'];
}
/**
* Get FileUploader configurations
*
* @return array<string, string>
*/
protected static function getConfig(): array
{
$config = config(FileUploaderServiceProvider::$abstract);
return empty($config) ? [] : Arr::wrap($config);
}
/**
* Create a streamed response for a given file.
*
*
* @return StreamedResponse Content
*/
public static function get(string $path, string $disk = null): StreamedResponse
{
return Storage::disk(self::getDisk($disk))->response($path);
}
/**
* Create a streamed response for a given file.
*
*
* @return string|null Content
*
* @throws MissingFile
*/
public static function getFile(string $path, string $disk = null): ?string
{
if (! Storage::disk(self::getDisk($disk))->exists($path)) {
throw new MissingFile("File $path does not exists.");
}
return Storage::disk(self::getDisk($disk))->get($path);
}
/**
* Get public path url.
* Mainly used to access public files.
*/
public static function url(string $path, string $disk = null): string
{
return Storage::disk(self::getDisk($disk))->url($path);
}
/**
* Get file path.
*/
public static function path(string $path, string $disk = null): string
{
return Storage::disk(self::getDisk($disk))->path($path);
}
/**
* Download a specific resource
*
* @param string|null $name name with extensions.
*/
public static function download(string $path, string|null $name, string $disk = null): StreamedResponse
{
return Storage::disk(self::getDisk($disk))->download($path, $name);
}
/**
* Get Visibility of a file
*
* @return string public|private
*/
public static function getVisibility(string $path, string $disk = null): string
{
return Storage::disk(self::getDisk($disk))->getVisibility($path);
}
/**
* Set Visibility of a file
*/
public static function setVisibility(string $path, string $visibility, string $disk = null): bool
{
if (! in_array($visibility, self::$validOptions, true)) {
return false;
}
return Storage::disk(self::getDisk($disk))->setVisibility($path, $visibility);
}
/**
* Delete file from disk
*
* @throws MissingFile
*/
public static function remove(string $path, bool $throwError = true, string $disk = null): bool
{
if ($throwError && ! Storage::disk(self::getDisk($disk))->exists($path)) {
throw new MissingFile('File does not exist!');
}
return Storage::disk(self::getDisk($disk))->delete($path);
}
/**
* Get meta data for a specific file.
*
*
* @return array<string, mixed>
*/
public static function meta(string $path, string $disk = null): array
{
$diskFrom = Storage::disk(self::getDisk($disk));
return [
'path' => $diskFrom->path($path),
'url' => $diskFrom->url($path),
'visibility' => $diskFrom->getVisibility($path),
'mimeType' => $diskFrom->mimeType($path),
'size' => self::formatBytes($diskFrom->size($path)),
'last_modified' => Carbon::createFromTimestamp($diskFrom->lastModified($path))->diffForHumans(),
'name' => basename($path),
];
}
/**
* Get all extensions
*
* @return array<int, string> Extensions of all file types
*/
public static function allExtensions(): array
{
return array_merge(self::$image_ext, self::$audio_ext, self::$video_ext, self::$document_ext, self::$archives_ext, self::$font_ext);
}
/**
* Get all allowed image extensions
*
* @return array<int, string>
*/
public static function images(): array
{
return self::$image_ext;
}
/**
* Get all allowed document extensions
*
* @return array<int, string>
*/
public static function documents(): array
{
return self::$document_ext;
}
/**
* Get type by extension
*
* @param string $ext Specific extension
* @return string Type
*/
private static function getType(string $ext): string
{
if (self::in_array($ext, self::$image_ext)) {
return self::IMAGE;
}
if (self::in_array($ext, self::$audio_ext)) {
return self::AUDIO;
}
if (self::in_array($ext, self::$video_ext)) {
return self::VIDEO;
}
if (self::in_array($ext, self::$document_ext)) {
return self::DOCUMENT;
}
if (in_array($ext, self::$font_ext)) {
return self::FONT;
}
if (in_array($ext, self::$archives_ext)) {
return self::ARCHIVE;
}
return self::FILE;
}
private static function defaultSanitizer(string $fileName): string
{
$fileName = (string) preg_replace('#\p{C}+#u', '', $fileName);
return str_replace(['#', '/', '\\', ' '], '-', $fileName);
}
/**
* Get directory for the specific user
*
* @return string Specific user directory
*
* @example uploads/{user_id}/{type}/{filename}
*/
private static function getUserDir(string $filename, string $type = self::FILE, int $user_id = null): string
{
$defaults = self::getConfig();
$dir = $defaults['path'] ?? self::UPLOAD_PATH;
return trim(strtr($dir, [
'{user_id}' => $user_id,
'{type}' => $type,
'{filename}' => $filename,
]), '/\\');
}
/**
* Grab dimensions of an image.
*
* @return string|null string|null
*/
private static function getDimensions(UploadedFile $file, string $type = self::IMAGE): ?string
{
if ('image' !== $type) {
return null;
}
if (self::isValidFileInstance($file) && $file->getClientMimeType() === 'image/svg+xml') {
return null;
}
if (! self::isValidFileInstance($file) || ! $sizeDetails = @getimagesize($file->getRealPath())) {
return null;
}
[$width, $height] = $sizeDetails;
return $width.'x'.$height;
}
/**
* Check that the given value is a valid file instance.
*/
private static function isValidFileInstance(mixed $file): bool
{
if ($file instanceof SymfonyUploadedFile && ! $file->isValid()) {
return false;
}
return $file instanceof SymfonyFile;
}
/**
* @param array<string> $haystack
*/
private static function in_array(string $needle, array $haystack): bool
{
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
/**
* get icon path
*/
public static function getIconPath(string $mimeType): string
{
$file_type_icons_path = 'img'.DIRECTORY_SEPARATOR.'file-type-icons'.DIRECTORY_SEPARATOR;
$icon_file = match ($mimeType) {
'image/jpeg', 'image/pjpeg', 'image/x-jps' => 'jpeg.png',
'image/png' => 'png.png',
'image/gif' => 'gif.png',
'image/bmp', 'image/x-windows-bmp' => 'bmp.png',
'text/html', 'text/asp', 'text/javascript', 'text/ecmascript', 'application/x-javascript', 'application/javascript', 'application/ecmascript' => 'html.png',
'text/plain' => 'conf.png',
'text/css' => 'css.png',
'audio/aiff', 'audio/x-aiff', 'audio/midi' => 'midi.png',
'application/x-troff-msvideo', 'video/avi', 'video/msvideo', 'video/x-msvideo', 'video/avs-video' => 'avi.png',
'video/animaflex' => 'fla.png',
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-word.document.macroEnabled.12', 'application/vnd.ms-word.template.macroEnabled.12', 'application/vnd.oasis.opendocument.text', 'application/vnd.apple.pages', 'application/vnd.ms-xpsdocument', 'application/oxps', 'application/rtf', 'application/wordperfect', 'application/octet-stream' => 'docx.png',
'application/x-compressed', 'application/x-7z-compressed', 'application/x-gzip', 'application/zip', 'multipart/x-gzip', 'multipart/x-zip' => 'zip.png',
'application/x-gtar', 'application/rar', 'application/x-tar' => 'rar.png',
'video/mpeg', 'audio/mpeg' => 'mpeg.png',
'application/pdf' => 'pdf.png',
'application/mspowerpoint', 'application/vnd.ms-powerpoint', 'application/powerpoint' => 'ms-pptx.png',
'application/excel', 'application/x-excel', 'application/x-msexcel', 'application/vnd.apple.numbers', 'application/application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.ms-excel.sheet.macroEnabled.12', 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'ms-xlsx.png',
'image/vnd.adobe.photoshop' => 'psd.png',
'not-found' => 'not-found.png',
default => 'unknown.png',
};
return $file_type_icons_path.$icon_file;
}
/**
* getFileType
* Return file mimetype default: 'application/octet-stream'
*/
public static function getFileType(string $filename): bool|string
{
$mime_types = [
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms-office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
];
$arr = explode('.', $filename);
$ext = strtolower(array_pop($arr));
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
} elseif (function_exists('finfo_open')) {
$fileInfo = finfo_open(FILEINFO_MIME);
if ($fileInfo) {
$mimetype = finfo_file($fileInfo, $filename);
finfo_close($fileInfo);
return $mimetype;
}
}
return 'application/octet-stream';
}
/**
* helper to format bytes to other units
*
* @param int $size in-bytes
*/
public static function formatBytes(int $size, int $precision = 2): string
{
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$bytes = max($size, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision).' '.$units[$pow];
}
/**
* converts KB,MB,GB,TB,PB,EB,ZB,YB to bytes
*
*
* @example 1KB => 1000 (bytes)
*/
public static function convertToBytes(string $from): float|int|string
{
$number = (int) substr($from, 0, -2);
return match (strtoupper(substr($from, -2))) {
'KB' => $number * 1024,
'MB' => $number * pow(1024, 2),
'GB' => $number * pow(1024, 3),
'TB' => $number * pow(1024, 4),
'PB' => $number * pow(1024, 5),
'EB' => $number * pow(1024, 6),
'ZB' => $number * pow(1024, 7),
'YB' => $number * pow(1024, 8),
default => $from,
};
}
/**
* Convert bytes to the unit specified by the $to parameter.
*
* @param int $bytes The filesize in Bytes.
* @param string $to The unit type to convert to. Accepts KB, MB, GB, TB or PB for Kilobytes, Megabytes, Gigabytes, Terabytes or PetaBytes, respectively.
* @param int $decimal_places The number of decimal places to return.
* @return string Returns only the number of units, not the type letter. Returns 0 if the $to unit type is out of scope.
*
* @example 1024 (KB) => 1MB
*/
public static function convertBytesToSpecified(int $bytes, string $to = 'MB', int $decimal_places = 2): string
{
$formulas = [
'KB' => number_format($bytes / 1024, $decimal_places),
'MB' => number_format($bytes / pow(1024, 2), $decimal_places),
'GB' => number_format($bytes / pow(1024, 3), $decimal_places),
'TB' => number_format($bytes / pow(1024, 4), $decimal_places),
'PB' => number_format($bytes / pow(1024, 5), $decimal_places),
'EB' => number_format($bytes / pow(1024, 6), $decimal_places),
'ZB' => number_format($bytes / pow(1024, 7), $decimal_places),
'YB' => number_format($bytes / pow(1024, 8), $decimal_places),
];
return isset($formulas[$to]) ? $formulas[$to].$to : 0 .$to;
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace ErlandMuchasaj\LaravelFileUploader;
//use Illuminate\Foundation\Application as Laravel;
use Illuminate\Support\ServiceProvider;
class FileUploaderServiceProvider extends ServiceProvider
{
/**
* Package name.
* Abstract type to bind FileUploader as in the Service Container.
*/
public static string $abstract = 'file-uploader';
public function register(): void
{
$this->mergeConfigFrom(
__DIR__.'/../config/file-uploader.php',
static::$abstract
);
}
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/file-uploader.php' => config_path(static::$abstract.'.php'),
], 'config');
}
}
/**
* Get the services provided by the provider.
*
* @return array<int, string>
*/
public function provides(): array
{
return [static::$abstract];
}
}