User provided image url verification

Hi everyone,

I would like to let the user provide an image url, but before pushing it into the database, i want to make sure the url is actually an image, if it is not, then i just skip the image url field.

i would like to know a way to verify if the url provided leads to an image, client and more importantly server side ; I already use a regular expression as a first filter, but i would like to go further.

Thanks.

Use the HTTP package to make a HEAD request to the url, and check the “content-type” header :slight_smile:

Btw, don’t make your regex require that the url ends in .filetype, as websites sometimes use ? parameters for thumbnails, tracking and such.

1 Like

Hmm alright, i will definitely look into it. Thank you.