Skip to content

Commit

Permalink
fix: Compatibility with the latest Leaf\FS package
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnsultan authored Dec 23, 2024
1 parent 7a8500a commit e276d90
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ public static function upload(string $key, string $destination, array $config =
}
}

$fileSystem = new \Leaf\FS;
$fileSystem = new \Leaf\FS\File;

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

$uploadedFile = $fileSystem->uploadFile(
$uploadedFile = $fileSystem->upload(
$file,
preg_replace(
'/\/$/',
Expand All @@ -454,12 +454,7 @@ public static function upload(string $key, string $destination, array $config =
$config
);

if (!$uploadedFile) {
static::$errors = $fileSystem->errors();
return false;
}

return $fileSystem->uploadInfo($uploadedFile);
return $uploadedFile;
}

/**
Expand All @@ -472,8 +467,10 @@ public static function upload(string $key, string $destination, array $config =
*/
public static function uploadAs(string $key, string $destination, string $name, array $config = [])
{
$config['name'] = $name;
$fileExtension = pathinfo($_FILES[$key]['name'], PATHINFO_EXTENSION);

$config['rename'] = true;
$config['name'] = $name . '.' . $fileExtension;

return static::upload($key, $destination, $config);
}
Expand Down

0 comments on commit e276d90

Please sign in to comment.