From: Vincent Vanwaelscappel Date: Thu, 14 Oct 2021 14:18:29 +0000 (+0200) Subject: wip #4791 @0:15 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b2e9111de7e7affc7456a4b7de6d4e97440193bc;p=cubist_cms-back.git wip #4791 @0:15 --- diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index e7d8655..e43092f 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -18,6 +18,7 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Str; use Spatie\MediaLibrary\MediaCollections\Models\Media; +use Symfony\Component\HttpFoundation\File\UploadedFile; class CubistMagicController extends CubistCrudController { @@ -358,13 +359,15 @@ class CubistMagicController extends CubistCrudController { $entry = $this->crud->getEntry($id); /** @var Media $media */ + /** @var UploadedFile $file */ $file = request()->files->get('file'); - $e = explode('.', $file['name']); + $e = explode('.', $file->getFilename()); $ext = array_pop($e); $fname = implode('.', $e); $fname = Str::slug($fname); - $file['name'] = $fname . '.' . $ext; - request()->files->set('file', $file); + + $nfile = new UploadedFile($file->getPath(), $fname . '.' . $ext, $file->getMimeType(), $file->getError()); + request()->files->set('file', $nfile); $media = $entry->addMediaFromRequest('file')->toMediaCollection($request->input('collection'));