Skip to content

Commit e276d90

Browse files
authored
fix: Compatibility with the latest Leaf\FS package
1 parent 7a8500a commit e276d90

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Request.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,13 @@ public static function upload(string $key, string $destination, array $config =
438438
}
439439
}
440440

441-
$fileSystem = new \Leaf\FS;
441+
$fileSystem = new \Leaf\FS\File;
442442

443443
if (!isset($config['rename']) || !$config['rename']) {
444444
$config['unique'] = true;
445445
}
446446

447-
$uploadedFile = $fileSystem->uploadFile(
447+
$uploadedFile = $fileSystem->upload(
448448
$file,
449449
preg_replace(
450450
'/\/$/',
@@ -454,12 +454,7 @@ public static function upload(string $key, string $destination, array $config =
454454
$config
455455
);
456456

457-
if (!$uploadedFile) {
458-
static::$errors = $fileSystem->errors();
459-
return false;
460-
}
461-
462-
return $fileSystem->uploadInfo($uploadedFile);
457+
return $uploadedFile;
463458
}
464459

465460
/**
@@ -472,8 +467,10 @@ public static function upload(string $key, string $destination, array $config =
472467
*/
473468
public static function uploadAs(string $key, string $destination, string $name, array $config = [])
474469
{
475-
$config['name'] = $name;
470+
$fileExtension = pathinfo($_FILES[$key]['name'], PATHINFO_EXTENSION);
471+
476472
$config['rename'] = true;
473+
$config['name'] = $name . '.' . $fileExtension;
477474

478475
return static::upload($key, $destination, $config);
479476
}

0 commit comments

Comments
 (0)