How should I set data type for my media using laravel nova spatie media library

659 Views Asked by At

I would like to be able to only upload PDF.

I have seen methods here acceptsFile or acceptsMimeTypes that could do the trick, but it seems that it will give an error at submiting the file.

I was loooking for a way to only be able to select pdf.

With the built-in laravel File resource, I was able to use :

->acceptedTypes('.pdf')

How should I do this with this plugin ?

1

There are 1 best solutions below

2
On

If I understand correctly, your problem does not reside in Laravel.

To be able to select only PDF files in the browser, specify the content type in the HTML source:

<input type="file" name="upload" accept="application/pdf" />

Check it out :)