Level 3
Did you setup the correct enctype in your form?
Hello,
i'm quite new to laravel and have an issue where i'm kinda stuck.
I'm using the MediaLibrary package from spatie and i'm trying to store an image that has beeen uploaded.
Everything works fine, expect that the image is not stored and no recored is placed in the database.
Maybe someone can help me out.
Thanks!
MediaController
<?php
namespace App\Http\Controllers;
use App\Media;
use Illuminate\Http\Request;
class MediaController extends Controller
{
// Hintergrund Polygon hinzufügen
public function addBackgroundImage(Request $request)
{
// Media::create()
// ->addMediaFromRequest('background')
// ->toMediaCollection();
$media = new Media;
$media->addMediaFromRequest('background')
->toMediaCollection('backgrounds');
return redirect('/settings')->with('success', 'Hintergrund Bild hinzugefügt');
}
}
Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\HasMedia;
class Media extends Model implements HasMedia
{
use HasMediaTrait;
}
Thanks!
Please or to participate in this conversation.