Issue using FileUpload on filament
When uploading an image, I can save it locally in storage/public. Im able to store pictures on a record when I save, but when I click back on that record (from a row), I dont see the image.
40 Replies
So, despite saving, I cant see the picture I uploaded in the post above
Here is the code that is used in the resource:
What console errors are you seeing?
I am seeing no errors, just no image on the page
Step one. Verify it’s getting saved correctly to the database for the record.
Can you please elaborate on this?
Check your database and see if the file path is actually saved to the table.
I know that I should add a string, where its saves the Hash of the name of the picture\
It isnt, at least I doubt that it is
Check. I need to know if it’s there or not to help further.
No, it is not saved
Is ‘attachment’ a relationship? Why isn’t it a field on the expense model?
I will change it from fillable to field
The issue now is that it just keeps loading, but only the filename is saved in the attachment
Something else is going on. Since you tinker is not showing an attachment field on the model in your screen shot. Is it even a field on your db schema.
It is showing now! I managed to fix it
Ok that looks right.
Make sure your APP_URL is setup correctly in your .env file and you have run
php artisan storage:link
yep, those were the first things I did
Do you have any console errors now.
In the browser.
Not any
Just the image not loading when I press create or when I click on a record
For example now
Not sure then. Sorry. Run a search on here. Others have had similar issues in the past.
Okay. Thank you for your help so far
Surprised there’s no errors. Typically file pond does that when it can’t find the image which usually shows up as console 404s for the image path.
omg
I went on a quick rabbit hole
All I had to do, is change the APP_URL
It was APP_URL=http://127.0.0.1 which always worked fine
I changed it to: APP_URL=http://127.0.0.1:8000
Now it works!
Lol. Glad you found it.
Another question. The name of the file is a hash, which in my opinion is a good thing. Imagine if 2 people upload 2 files with the same name, then we have a big problem, right? Because we dont know where which file is referenced on that record.
There is an option to preserve the file name. Will that create the issue that I mentioned above?
Also a good reason to use something like valet, sail or homestead so you get an actual domain name instead of having to worry about ports.
Technically, yes. What would happen in that case is the newest one coming in would over write the old one. But you can use -> getUploadedFileNameForStorageUsing() to override that to check for the existence of a file first and append something like ‘-1’ etc to it.
It’s in the docs.
I think this is a better solution, because from what I understand, the hash will correspond to the original file name
BUt what is attachment_file_names?
Honestly I’m not sure. I don’t know how that part works. Lol.
Probably requires another table column.
well, anyways, I feel like I made very good progress today. I will see again tomorrow. Again, thanks for the help!
It does
and it preserves the name, it just doesnt rename
No worries. Glad you got it working.
This is in the form
And is formatted properly
Here is in the table, but I cant find a way to format it in d/m/y
might just make a datepicker at this point
TextColumn has methods for displaying dates.
As long as it’s cast as a date or datetime on the model.
Filament
Text column - Columns - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Please have a look through the docs.
It’ll save you a lot of trouble to at least read through them once and not just look at them on a per case basis.
Yep I actually did. It was my mistake though because I type DateTime, and not DatePicker