Jump to content

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.