File Upload within a custom page is null
So My page resource
And my form im using the spatie media library file upload component
But in my dd() I only see name, there is nothing regarding the file upload part. Is there something im missing that I cant see in the documentation?
Solution:Jump to solution
So something like this
```php
public function submit()
{
$model = MyModel::create($this->form->getState());...
9 Replies
So, if I use FileUpload::make(), it appears to work, but the Spatie one doesnt... but the documentation says the Spatie one is used the same way as the FileUpload component?

Try
$data = $this->form->getRawState();
Also look at the FileUpload::getUploadedFileNameForStorage
. Or you can override the fileupload process using ->saveUploadedFileUsing()
Anyway yeah file uploads are a bit of a pain if you want to do custom stuff.So does using getRawState() not handle the actual uploading part? Assuming Id then have to do that overriding to manage how and where data is uploaded?
I'm not sure what you want to do so I just posted some stuff that might help. A lot of the details depend on other configs - eg what's the default storage? Is it locally or some other service like S3? Do you want to override the upload process entirely or just do something else after the upload is done?
I don't remember much, but here is a snippet of how I used the raw data to send an email with the file uploads as attachemts
and then
There might be a better way to do this, but I hope this helps in what you're trying to do
The main use is default, it's just trying to put it on a custom page, rather than a resource. So I've setup the form as normal, and im trying to use the spatie media library (https://filamentphp.com/plugins/filament-spatie-media-library#form-component). But the basic usage set out in the docs doesn't appear to be working.
Not adding anything extra currently
So you just want to save the file? Do you have a
$this->form->model($model)->saveRelationships();
call?Solution
So something like this
So you just want to save the file?At present, yes. When I use the SpatieMediaLibraryFileUpload component (from spatie docs), my data from form->getState or getRawState is null, but if I use Filaments default FIleUpload, it returns string as normal etc. Im still trring to associate that file with the Spatie media mainly for file information etc, but just cant obtain the 'document' Not using saveRelationships as of yet, will give that a go Yeah, so the combination of the relationship, and changing the morphs model to be a uuid, looks like its working. Thank you