Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accept method #166

Open
vasishakd opened this issue Apr 6, 2020 · 7 comments
Open

Add accept method #166

vasishakd opened this issue Apr 6, 2020 · 7 comments

Comments

@vasishakd
Copy link

There is no way to limit file extensions on file selection dialog. It would be nice if you could use the accept method, to add html attribute accept.

@VeeeneX
Copy link
Collaborator

VeeeneX commented Apr 6, 2020

You can define rule for validation if that's what you looking for:
https://laravel.com/docs/7.x/validation#rule-mimetypes

use Ebess\AdvancedNovaMediaLibrary\Fields\Images;

public function fields(Request $request)
{
    return [
        Images::make('Images', 'my_multi_collection')
            ->rules('mimes', 'jpeg,bmp,png')
    ];
}

I have not tested it.

@vasishakd
Copy link
Author

You can define rule for validation if that's what you looking for:
https://laravel.com/docs/7.x/validation#rule-mimetypes

use Ebess\AdvancedNovaMediaLibrary\Fields\Images;

public function fields(Request $request)
{
    return [
        Images::make('Images', 'my_multi_collection')
            ->rules('mimes', 'jpeg,bmp,png')
    ];
}

I have not tested it.

Rules applies after form submission but i need add html accept attribute

@sonofascoby
Copy link

I think I'm having the same issue as @vasishakd .

For example, setting ->rules('mimes', 'jpeg,bmp,png')applies the validation on the server-side but on the client-side still allows users to select other file formats like .pdf, .txt, .doc etc.

@pavlovpa4o
Copy link

@ebess If I make PR would you merge it?

@bkintanar
Copy link
Collaborator

@pavlovpa4o go ahead.

@LiamKarlMitchell
Copy link

related to #94, #330
there is a pr on 330, by the look of it, may be possible to extract the types from the mimes rule :)

@pratikdzignuts
Copy link

Hello @VeeeneX
I am using below code in my nova project but it's not allowing upload jpeg file. can you help me how to upload jpeg file.
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;

public function fields(Request $request)
{
return [
Images::make('Images', 'my_multi_collection')
->rules('mimes', 'jpeg,bmp,png')
];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants