Jump to content

Form input has to be a .gif


Monkuar

Recommended Posts

In my Photo Gallery, people submit photo's but it's a .gif or .jpg for the photo, how can I use php to help me on if a user doesnt have a .gif or a .jpg at the end of the url and then it gives them "Error Hey u need a .gif or .jpg at the end to submit"

 

thanks.

 

EDIT: They dont upload it's just a link to the image.

Link to comment
https://forums.phpfreaks.com/topic/164473-form-input-has-to-be-a-gif/
Share on other sites

Well, You get the length of the string: http://php.net/manual/en/function.strlen.php

 

You take that number and subtract 4 from it. This way you will have your starting value for a substring function: http://be2.php.net/substr

 

And then you compare that to the string ".jpg" or ".gif" or something like that.

 

I would put every letter in a for loop and then use strtolower (http://php.net/manual/en/function.strtolower.php) or (http://php.net/manual/en/function.strtoupper.php) to compare. Since caps are not the same as small letters. But maybe there's a better way to do so.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.