3 years ago

Validating Image URL?

Posted 3 years ago by xdega

So I have the following validation logic in my controller:

        $rules = array(
            'avatar'        => array('url', 'regex:~^https?://(?:[a-z0-9\-]+\.)+[a-z]{2,6}(?:/[^/#?]+)+\.(?:jpe?g|gif|png)$~'),

This works on a rudimentary level. It lets me check that an image URL is being provided. The problem is that it doesn't check if said image is a broken link.

Does anyone have any idea on how I could approach this problem? I am kinda stuck.

Please sign in or create an account to participate in this conversation.