Programming Skills
Programming Skills

Reputation: 233

Check if image content is a valid image code

Is there any way to check if the image code inside it is valid because

some crackers(hackers) can change the extension and play with image info using some applications to trick the website that the type is image while it's not

so is there any way to check if content is an image code ?

Or is there anyway to check against this type of attacks ?

Upvotes: 1

Views: 788

Answers (1)

Shree Sthapit
Shree Sthapit

Reputation: 316

For Multiple Images

$validatedData = $request->validate([
    'images' => 'required',
    'images.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
]);

Single Image Validation

$validatedData = $request->validate([
    'image' => 'required',
    'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
]);

Upvotes: 2

Related Questions